I was following SuiteAnswers: Answer Id: 44790, but am obviously missing something. I will first note that I am working in our Sandbox and have no experience with scripting. I am hoping this would be an easy answer for someone in this forum.
1. I started by creating a custom transaction body field on our Sales Order form. Field ID: 'custbody_dlw_originating_record'
2. Create a Client Script with a pageInit function using the sample code below
3. The script looks like this:
function getSourceID(type){
if (type = 'copy'){
var entryForm = nlapiGetFieldValue('entryformquerystring');
if (entryForm.charAt(0) == 'r'){
var entryForm_substr = entryForm.substr(8);
var start_pos = entryForm_substr.indexOf("=");
var entryForm_subtr_two = entryForm_substr.slice(start_pos);
var ampPos = entryForm_subtr_two.indexOf("&");
var sourceID = entryForm_subtr_two.slice(1, ampPos);
nlapiSetFieldValue('custbody_dlw_originating_record', sourceID);
}
}
}
4. In NetSuite, I have created a new client script and uploaded the script file (with the above code).
5. I added the text: nlapiGetFieldValue to the Page INIT Function field on the script record.
6. I added a Scrip Deployment that
a. APPLIES TO: Sales Order
b. DEPLOYED: Checked
c. STATUS: Released
d. EVENT TYPE:
e. LOG LEVEL: Error
7. When I copy and order, the originating sales order number does not populate into my custom field.
8. I have tried a number of changes/scenarios, but not being familiar with the language I am just guessing.
Thank you in advance for any assistance.