Before insert BR
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 12:50 AM - edited 06-16-2025 02:55 AM
Hi All,
Can anyone help me to figure out there is before insert BR to update the shipping instruction field value append with the purchase reason field value.
There are 3 different types values in purchase reason field for one of the case it's working fine for 1-2 case it's not working.
(function executeRule(current, previous /*null when async*/ ) {
function toTitleCase(str) {
return str
.toLowerCase()
.replace(/[^a-zA-Z0-9 ]/g, '') // Remove special characters but keep spaces
.replace(/\b\w/g, function(match) {
return match.toUpperCase(); // Capitalize first letter of each word
});
}
var titleCaseReason = toTitleCase(current.purchase_reason.toString());
//var originalShippingInstruction = '';
var originalShippingInstruction = current.u_shipping_instructions.toString();
//current.u_shipping_instructions = ' ';
current.u_shipping_instructions = titleCaseReason + ': ' + originalShippingInstruction;
})(current, previous);