Issue
User is experiencing “Error Parsing XML: The entity name must immediately follow the ‘&’ in the entity reference” whenever it triggers the script that prints the name of the Customer.
Solution
This error is caused by the ‘&’ in the Customer name of record wherein the script is reading this as an operator. In order to fix this error, the ‘&’ in the customer name must be replace by ‘&’.
var name= depositRecord.getSublistText({sublistId: 'payment', fieldId: 'entity', line: 0})
var andName = name.match('&')
if(andName){
name = name.replace(/&/g, "&");
xml += '' + name + '\n';
}