This topic contains 1 reply, has 0 voices, and was last updated by starlingMark 6 years, 5 months ago.
-
AuthorPosts
-
June 7, 2018 at 9:32 am #17772
dbetlowI have an interesting problem I’m trying to solve. The phone number of a subrecord address doesn’t show up on the transaction form as part of the address. Because UPS and Fedex require phone number when shipping, the user has to edit the sales order and edit the address in order to see the phone number field…
I’d like to retrieve the phone number field from the subrecord shipping address and display it as a transaction body field.
The following code works for a client script. However, I don’t want the user to have to edit the record to see the phone number. I’d like to make this work as a User Event script, but it seems I can’t update the field in either a BeforeLoad or BeforeSubmit. The field doesn’t store a value, it is just used to display the value. I could make the field store a value, but then it would only work for transactions going forward, not previously created ones…
Code:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/define([ ‘N/record’ ],
function(record) {
function pageInit(context) {
// Load the record.
var rec = context.currentRecord;
// Retrieve the subrecord.
var subrec = rec.getSubrecord({
fieldId: ‘shippingaddress’
});// Create a variable and initialize it to the
// value of the subrecord’s phone field.var phoneValue = subrec.getValue({
fieldId: ‘addrphone’
});rec.setValue({
fieldId: ‘custbody37’,
value: phoneValue,
ignoreFieldChange: true,
fireSlavingSync: true
});// Print the value to the execution log.
try {
log.debug({
title: ‘phone value’,
details: ‘phone value: ‘ + phoneValue
});} catch (e) {
log.error({
title: e.name,
details: e.message
});
}
}return {
pageInit: pageInit
}
});
This is a cached copy. Click here to see the original post. -
June 14, 2018 at 1:02 pm #17773
starlingMarkHave you considered having the field not store the value but populate it with a saved search? Details can be found in the NS help file here:
https://system.na3.netsuite.com/app/…_N2830711.html
-
AuthorPosts
You must be logged in to reply to this topic.