Hello Everyone,
I can't figure out how to turn shipmethod id into text that is sourced from SO on Invoice using searching in SuiteScript 1.0, I tried to use getFieldText and getFieldTexts functions. Both didn't work.
Currently, script is souring shipmethod id instead of text value.
function setSOColFieldsonSO_afterSubmit_UE(type) {
//internal ID of the Invoice
var inv_internalID = nlapiGetRecordId();
//load the Invoice record
var inv = nlapiLoadRecord('invoice', inv_internalID);
//internal ID of the Sales Order that the Invoice was created from
var createdFromSO = inv.getFieldValue('createdfrom');
//if the Created From field on the Invoice has a value, do the following:
if ((createdFromSO != "") && (createdFromSO != null)) {
//conduct search to obtain value of custom transaction line fields on the Sales Order that the Invoice was created from
//search filters:
//- Invoice with the current Invoice's Internal ID
//- Mainline is True
//- Applied to Transaction is Sales Order
//- Applied to Transaction (Sales Order) of the Invoice is the same as the Sales Order that the Invoice was created from
var filters = new Array();
filters[0] = new nlobjSearchFilter('internalid', null, 'is', inv_internalID);
filters[1] = new nlobjSearchFilter('mainline', null, 'is', 'T');
filters[2] = new nlobjSearchFilter('type', 'createdfrom', 'is', 'SalesOrd');
filters[3] = new nlobjSearchFilter('createdfrom', null, 'is', createdFromSO);
//search columns:
// - Applied To Transaction (Sales Order) Internal ID
// - Custom Transaction Line Fields from the Applied to Transaction (Sales Order)
var columns = new Array();
columns[0] = new nlobjSearchColumn('createdfrom');
columns[1] = new nlobjSearchColumn('shipmethod', 'createdfrom');
//(can add more Custom Transaction Line Fields from the Sales Order here)
//perform search
var searchResults = nlapiSearchRecord('invoice', null, filters, columns);
//if there are results from the search, do the following:
if (searchResults) {
//get value of the first search result's (there should be only one search result) to Custom Transaction Line Fields from the Sales Order
var myCustTransColFieldfromSO = searchResults[0].getValue('shipmethod', 'createdfrom');
//(can add more Custom Transaction Line Fields from the Sales Order here)
//set value of Custom Transaction Line Fields from the Sales Order onto the Custom Transaction Body Fields on the Invoice
inv.setFieldValue('custbody_shippingcarrier_adv_pdf', myCustTransColFieldfromSO);
//save the Invoice
nlapiSubmitRecord(inv);
}
}
}
Thank you!
Lana.