0
votes

In NetSuite, how do I populate a custom transaction field

(custbody_site_no_shipto) 

on a transaction (for example, a Sales Order) with a custom address field

(custrecord_site_no) 

for the Ship-To Address selected (under the Shipping tab)?

 Custom transaction field: custbody_site_no_shipto
 (Menu: Customization > Lists, Records, & Fields > Transaction Body   Fields – Display Type is Inline Text).

 Custom address field: custrecord_site_no
 (Menu: Customization > Lists, Records, & Fields > Other Custom Fields –    Checked Apply To All Custom Address Forms).
2
What is the data type for 'custbody_site_no_shipto'? Also, tell me more about the Ship-To-Address field. What is its type?TonyH
Both the custom fields are Free-Form Text. Did that answer your question?InigoMontoya
You would typically set up this kind of relationship using Sourcing on your custbody_site_no_shipto definition. You would set the Source List to Shipping Address and the Source From to your custrecord_site_no. Unfortunately, Shipping Address is not an option, only Ship To, which points to the Contact, not the Address.erictgrubaugh

2 Answers

0
votes

Usually, you would configure the sourcing of the custom field on the 'Sourcing and Filtering'.
However, shipping address is not included the 'Source List'.
So to cater that requirements, you might only do automation/customization either by SuiteFlow or SuiteScript (Client Side or User Event script).

And looking to your requirements, it seems you can only do this using after submit user event script. It is because the "Address" you wanted to access is a subrecord and not all APIs for it can be used on client side script. I have example below:

    var recSO = nlapiLoadRecord('salesorder', 34826,
        {
            recordmode : 'dynamic'
        });//34826 is the internal id of SO
    var recSubAddress = recSO.viewSubrecord('shippingaddress');//Ship To field id
    var stSiteN0 = recSubAddress.getFieldValue('custrecord_site_no');

    recSO.setFieldValue('custbody_site_no_shipto', stSiteN0);
    var stRecId = nlapiSubmitRecord(recSO);
0
votes

The script below works and was implemented as a User Event Script.

function userEventBeforeSubmit(type) {
 var shipadd = nlapiGetFieldValue('shipaddresslist');
 var customer = nlapiGetFieldValue('entity');

 var record = nlapiLoadRecord('customer', customer,{recordmode: 'dynamic'});
 var linenum = record.findLineItemValue('addressbook', 'internalid', shipadd);


 record.selectLineItem('addressbook', linenum);
 var subrecord = record.viewCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
 var customfield1 = subrecord.getFieldValue('custrecord_site_no'); 
 nlapiSetFieldValue('custbody_site_no_shipto', customfield1);
}