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'); } } }When I change the field value custbody_containerbillcount it successfully prompts for the action, I click ok, it manipulates my lines, but then it prompts again.I assume this is because the script is still sitting there and seeing that the initial if condition is met? In which case, how do I write a condition for a field to have a number entered, but then exit once the actions are complete?Thanks