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.
Keep an eye out for upcoming NetSuite events, including meetups, workshops, and webinars. These sessions are a great way to connect with peers, learn from experts, and stay current on the latest NetSuite updates and best practices. Registration links are provided in each event.
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