To get the data in a field, primarily by Text, if not present then by Value

/**
* To get the data in a field, primarily by Text, if not present then by Value
* @param {record} recordObj
* @param {String} fieldId
* @returns {undefined|*}
*/
const getTextOrValue = ({recordObj = transactionRecord, fieldId}) => {
try {
return recordObj.getText({fieldId}) || recordObj.getValue({fieldId});
} catch (err) {
return undefined;
}
};
/**
* To get the data in a sublist field, primarily by Text, if not present then by Value
* @param {record} recordObj
* @param {String} sublistId
* @param {String} fieldId
* @param {Number} line
* @returns {*}
*/
const getSublistTextOrValue = ({recordObj = transactionRecord, sublistId, fieldId, line}) => {
try {
return recordObj.getSublistText({
sublistId: sublistId,
fieldId: fieldId,
line: line
}) || recordObj.getSublistValue({
sublistId: sublistId,
fieldId: fieldId,
line: line
});
} catch (e) {
return undefined;
}
};

Leave a comment

Your email address will not be published. Required fields are marked *