Accessing data records
This script show you how to access the data record.
/**
* MyDatamerge Javascript (Examples: https://mydatamerge.com/javascript)
* This script illustrates on how to access data records
* It is for demonstration purposes and not recommended to use in production
*
* REQUIREMENTS:
* 1 .Write an existing column title in the "recordField" below
**/
// ENTER A VALID DATASOURCE COLUMN TITLE HERE
var recordField = "Last Name";
var prevRecordValue = prevRecord()[recordField];
var recordValue = currentRecord()[recordField];
var nextRecordValue = nextRecord()[recordField];
var result = "";
// Always check for undefined values (e.g. if previous record is not existant)
if (prevRecordValue != undefined){
result += "\nPrevious '" + recordField + "': " + prevRecordValue;
}
if (recordValue != undefined){
result += "\nCurrent '" + recordField + "': " + recordValue;
}
if (nextRecordValue != undefined){
result += "\nNext '" + recordField + "': " + nextRecordValue;
}
return result;