Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Stay in the Know
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Client Script Field Change Stuck in Loop
Hi Everyone,
I'm trying to use this field change trigger for the first time. I've run into a situation where it is performing the action I desire, however, I have a prompt inside the script that ends up popping up continuously.
function onFieldChange(type,name){ if(nlapiGetFieldValue('custbody_containerbillcount') != ''){ var totalBillAmount = nlapiGetFieldValue('usertotal'); var containerCount = nlapiGetFieldValue('custbody_containerbillcount'); var memoField = nlapiGetLineItemValue('expense','memo',1); var x = confirm("Do you want to split bill amount of "+ totalBillAmount + " into "+ containerCount + " line items."); if( x == true){ for(var j = 1; j <= containerCount; j++){ nlapiLogExecution('debug','Details','j = '+j); nlapiSelectLineItem('expense',j); nlapiSetCurrentLineItemValue('expense','account',487); nlapiSetCurrentLineItemValue('expense','amount',parseFloat(totalBillAmount)/parseInt(containerCount)); nlapiSetCurrentLineItemValue('expense','memo',memoField); nlapiSetCurrentLineItemValue('expense','class',45); nlapiSetCurrentLineItemValue('expense','department',1); nlapiSetCurrentLineItemValue('expense','location',1) nlapiCommitLineItem('expense'); } } else { alert('Action cancelled'); } } } 0