Monday, December 17, 2018

List all Sales Orders Related to a Project Record on One Custom Field Using SuiteScript

List all Sales Orders related to a Project Record on one custom Field using SuiteScript

Create a Custom Entity Field

Customization > Lists, Records, & Fields > Transaction Body Fields >

Label: Related Sales Order
Id: _txn
Type: Multiple Select
List/Record: Transaction

Applies To:
 Project: checked

Display:
 Subtab: Main
 Display Type: Inline Text 

Use the following Snippet on a Page Init Client Side Script

Customization > Scripting > Scripts > New > Client'

var filters = [];
filters.push(new nlobjSearchFilter('internalidnumber', 'job', 'equalto', nlapiGetRecordId()));
var columns = [];
columns.push(new nlobjSearchColumn('internalid'));
var searchResults = nlapiSearchRecord('salesorder', null, filters, columns);
var outputString = "";
for(var i = 0;i < searchResults.length;i++){
 var searchResult = searchResults[i];
 outputString += searchResult.getId() + String.fromCharCode("5");
}
nlapiSetFieldValue('custentity_txn', outputString);

No comments:

Post a Comment