I am trying to write a javascript code to be used in the Sales Order form. The scenario is this -- I am creating a letter template to be created from the Sales Order. The Sales Rep is mentioned in the letter, however, due to the way the system was set up and is used, all employees come out as Last Name, First Name in any outputs. I created a custom transaction body field called Employee Full Name in the Sales Order record. I also have a custom entity field tied to the Employee record called Employee Full Name (this is a free-form text field that is entered when a new employee is keyed in).
Here's the code I have so far, but I know it's not working properly. Any help would be appreciated.
function setSalesorder()
{
var salesrep = nlapiGetsalesrep ();
nlapiSetFieldText('custbody_sales_rep_name', nlapiGetFieldText('salesrep.custentity_employee_fullname')); }
Basically, I need to source the sales rep field of the Sales Order and output the Employee Full name field from the Employee record and store that in the Sales Rep name field of the Sales Order record.