Monday, May 20, 2019

Script > Set Request Read Receipt Checked for Purchase Order Emails

Use Case: Customer would like the Request Read Receipt checkbox in the Messages tab of an email to be default checked if the email is from a Purchase Order.

Create a Before Record Load User Event script that is deployed on the Message record as shown below:

function getTransaction(){
    var trans = nlapiGetFieldValue('transaction');

    if(trans  != null){
         var filters = new Array();
        filters[0] = new nlobjSearchFilter('internalid', null, 'is', trans);
        filters[1] = new nlobjSearchFilter('mainline', null, 'is', 'T');

        var column = new Array();
        column[0] = new nlobjSearchColumn('type');

        var result = nlapiSearchRecord('transaction', null, filters, column);
        var rec = result[0].getValue('type');

        if(rec == 'PurchOrd'){
                nlapiSetFieldValue('requestreadreceipt', 'T');
         } else{
                nlapiSetFieldValue('requestreadreceipt', 'F');

No comments:

Post a Comment