I'm sure this is a very basic question for advanced JS programmers, but I'm a newbie...so if someone could point me in the right direction that would be great.
Problem: I want to automatically populate the "Department" field on a Sales Order transaction form based on the Customer selected.
My Proposed Solution:
1. Created a custom field for the customer record called "custentity_cust_category" of type list/record that is sourced from the same list as the Department list. (this worked for me so far)
2. Create a Client SuiteScript that looks like this:
function postSourcing()
{
//set value of "department" for sales order equal to value of "department" from the customer record
var custname = nlapigetFieldValue("entity");
var orderdept = nlapiLookupField("entity", custname, "custentity_cust_category");
SetFieldValue("department", orderdept, true, true);
}
3. Expected Result - when I select a customer in the Sales Order form, Department should be populated based on that Customer's value in "custentity_cust_category". (similar to how the Sales Rep field is populated)
4. Actual Result - neverending loop that populates nothing
Hopefully someone has done something similar and can point me in the right direction. Is it my syntax, deployment, or what? thanks!