Thursday, November 29, 2018

Generate enum values of Country from client side script

Here the client side script that uses expressions to convert to the desired web serivce enum.

function getEnumVal(){
 var value = nlapiGetLineItemText('addressbook','country', 1); //1 us the line number

value='_'+((((value.replace(/[\-]/g,' ')).toLowerCase()).replace(/(^|\s)([a-z])/g,function(m,p1,p2){return p1+p2.toUpperCase();})).replace(/[^A-Za-z0-9_]/g,'')).replace(/^([A-Z0-9])/i,function(m,p1){return p1.toLowerCase();});


Above script would generate _unitedStates from United States.

No comments:

Post a Comment