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.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
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