0

Here is a code for auto populating a field in a sales order with a custom entity field.

function exampleFieldChangedFunction(type, name, linenum){
  if(name == 'entity'){ //this line will make sure that the field being changed is the 'customer' field
    var customerValue = nlapiGetFieldValue('entity');   //the value of the customer field

    var customerclassValue = nlapiLookupField('entity', customerValue, 'custentitykn_division_regions');    //Class value on the customer record

    var customerClass = nlapiLookupField('custentitykn_division_regions', customerclassValue, 'class');

    nlapiSetFieldValue('class', customerClass); //auto-populate Division/Region with the new customer's class value
  }
}
Rockstar
  • 2,228
  • 3
  • 20
  • 39
fbarriga
  • 35
  • 9
  • 2
    What problem are you experiencing? – erictgrubaugh Mar 14 '16 at 16:20
  • Code not running correctly not populating. – fbarriga Mar 14 '16 at 16:54
  • 2
    Do you get any error message? Either in alert or in console? The more details you give, the better we can help. – erictgrubaugh Mar 14 '16 at 22:52
  • 1
    can you please explain what you trying to do with this line of code : `nlapiLookupField('custentitykn_division_regions', customerclassValue, 'class')`? For performing Lookup the first parameter has to be a record type not a field value. – Rockstar Mar 15 '16 at 04:39
  • The type of record the field lists is class records for SUBDIVISION/REGION. Yes everyone has the right to view all Customers Division/Region records. – fbarriga Mar 15 '16 at 13:04
  • 'custentitykn_division_regions' is a custom field that resides in the customers record. It lists the customers subdivision and region. – fbarriga Mar 15 '16 at 13:04
  • The 'class' Field is listed in the sales order which I am trying to get it to auto populate the division and regions when the customer is chosen. – fbarriga Mar 15 '16 at 13:24

0 Answers0