Ok.. so I do need the pageInit and the postSource.
# suitescript
w
Ok.. so I do need the pageInit and the postSource.
j
pageInit for editing an order that already has a customer or clicking create sales order from customer record. postSourcing for when someone enters a new customer from a blank sales order or changes a customer on the sales order.
w
Ok.. that's what I had thought and had at first, but I kept getting errors about my (customer) variable. It seems that if I declare my variables globally nothing works right. I'll look at it all again.
I think I have something that works now. Thanks
// //Check if Customer is ON HOLD // //Will return a message when a Sales order is created from the Customer record or the Customer Field is filled in. function pageInit(type){ if (type === 'create'){ creditCheck(); return true; } return true; } // This will check for field change function postSource(type,name){ if (name === 'entity'){ creditCheck; return true; } return true; } function creditCheck(){ var company = nlapiGetFieldValue('entity'); alert(company); if (company != '' && company != null){ alert(company + 'Past IF Statement'); var customer = nlapiLoadRecord('customer',company); var creditholdoverride = customer.getFieldValue('creditholdoverride'); var consolbalance = customer.getFieldValue('consolbalance'); var consolunbilledorders = customer.getFieldValue('consolunbilledorders'); var creditlimit = customer.getFieldValue('creditlimit'); alert (customer.getFieldValue('entityid') + 'Before Credit Check') if((consolbalance+consolunbilledorders) > creditlimit && creditholdoverride != 'OFF'){ alert( 'Credit Limit reached' ); return true; } return true; } }