Set Tracking Link in Invoice

Jira Code: PROT-106

This client script will set the tracking link of the order to a custom field in invoice record.

define(['N/record'],
/**
 * @param {record} record
 */
function(record) {
    
   
    function pageInit(scriptContext) {
    	
    }

    function saveRecord(scriptContext){

    	try {    	    
        	var link = jQuery("a[name=linkedtrackingnumbers]").attr("href");
        	log.debug({
				title : 'link',
				details : link
			});
        	log.debug({
				title : 'link',
				details : link
			});
        	var invoicerecord = scriptContext.currentRecord;       
        	
        	invoicerecord.setText({
        	    fieldId: 'custbody_tracking_link',
        	    text: link,
        	    ignoreFieldChange: true
        	});       	
        	
    		} catch (e) {
    			log.debug({
    				title : 'err@pageint',
    				details : e
    			});
    		} 
    
    }

    return {
        pageInit: pageInit,
    	saveRecord : saveRecord
    };
    
});

Leave a comment

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