Global API
Apex Generator

Adding Standard Fields

4min
in this document, we will explain how to add any new standard field to the apex generator code this is an example of creating a sales order using an apex generator code the procedure is the same for other transactions in the below example, we will explain how to add the standard field called terms follow these two steps to add standard fields to the apex generator's code 1\ know the standard fields go to the respective global api request object look for the netsuite api name and datatype of the standard field you want to add example standard fields supported by the sales order docid\ emqjiknclze b zi9pinn 2\ declare the standard fields fields are declared/added inside the "requests" class so, navigate to the "requests" class, paste the below code snippet inside the "requests" class, and edit it as per the requirement ensure that the field label, description, datatype, and variable name match your netsuite standard field apex generator code //adding custom fields @invocablevariable(label='terms' description='terms') public string terms; //lookup 3\ initialize the standard fields and add them to the map standard fields should be initialized inside the "generatenetsuitesalesordermap" method to initialize the standard fields, paste the code snippet below in the "generatenetsuitesalesordermap" method after initializing the variable "netsuitesalesordermap" and edit them as required note terms is a reference field in netsuite, so we need to pass it's internalid apex generator code // initialize the standard fields if(req terms!= null) netsuitesalesordermap put('terms', new map\<string, object>{'internalid'=>req terms}); note the complete example is given below, and for the sake of code readability and length, a few fields that would auto populate by the apex generator are removed here apex generator code // start apex class public with sharing class createnssalesorderusingfuture { public createnssalesorderusingfuture() { } @invocablemethod(label='create netsuite sales order' description='create netsuite sales order') public static void createnetsuitesalesorderusingfuture(list\<requests> requestlist){ createnetsuitesalesorder(json serialize(requestlist)); } @future(callout = true) public static void createnetsuitesalesorder(string requestlistjson){ list\<requests> requestlist = (list\<requests>)json deserialize(requestlistjson, list\<requests> class); list\<object> netsuitesalesorderlist = new list\<object>(); for(requests req requestlist){ netsuitesalesorderlist add(generatenetsuitesalesordermap(req)); } // sending request to netsuite via exposed global api map\<string, object> reqjsonmap = new map\<string, object>(); reqjsonmap put('salesorders' , netsuitesalesorderlist); string reqjson = json serialize(reqjsonmap); map\<string, object> finalreqmap = new map\<string, object>(); finalreqmap put('version' , '1 0'); finalreqmap put('action' , 'createsalesorder'); finalreqmap put('requestjson' , reqjson); system debug('request ' + finalreqmap); map\<string, object> respmap = breadwinner ns breadwinnernetsuiteapi call(finalreqmap); system debug('response ' + respmap); } public class requests{ @invocablevariable(label='class' description='class') public string classification; //lookup @invocablevariable(label='created from' description='created from') public string createdfrom; //lookup @invocablevariable(label='currency' description='currency') public string currencyrecord; //lookup @invocablevariable(label='custom form' description='custom form') public string customform; //lookup @invocablevariable(label='department' description='department') public string department; //lookup @invocablevariable(label='discount item' description='discount item') public string discountitem; //lookup //adding standard fields @invocablevariable(label='terms' description='terms') public string terms; } public static map\<string, object> generatenetsuitesalesordermap(requests req){ map\<string, object> netsuitesalesordermap = new map\<string, object>(); // assign values from the request to netsuite sales order // initialize the standard fields if(req terms!= null) netsuitesalesordermap put('terms', new map\<string, object>{'internalid'=>req terms}); if(req classification != null) netsuitesalesordermap put('classification', new map\<string, object>{'internalid'=>req classification}); if(req currencyrecord != null) netsuitesalesordermap put('currencyrecord', new map\<string, object>{'internalid'=>req currencyrecord}); if(req customform != null) netsuitesalesordermap put('customform', new map\<string, object>{'internalid'=>req customform}); if(req createdfrom != null) netsuitesalesordermap put('createdfrom', new map\<string, object>{'internalid'=>req createdfrom}); if(req department != null) netsuitesalesordermap put('department', new map\<string, object>{'internalid'=>req department}); return netsuitesalesordermap; } }