Holds the execution context values for script triggers Supported script types – Client & Server side scripts Module – N/runtime module //Add additional code … if (runtime.executionContext !== runtime.ContextType.USEREVENT) return; … //Add additional code
Category: SuiteScript Functions
SuiteScript Functions related articles will be posted in this category
savedSearch1.concat(savedSearch2) method to merge 2 saved searches.
we can create 2 separate saved search and merge them as an array and can use it for accessing data using the .concat() method. Given below is an example of map/reduce script in which two searches are created in the getInputData() and use them in other stages by merging them as a single array. const… Continue reading savedSearch1.concat(savedSearch2) method to merge 2 saved searches.
SuiteScript 2.0 Error: no method getTime()
To get the date on a date or datetime field from a record such as that of startdate or lastmodifieddate, the string output from record.getValue() needs to be converted first to a date using N/format module’s format.parse() method. require([‘N/currentRecord’, ‘N/format’], function (nCurrentRecord, nFormat) { var currentRecord = nCurrentRecord.get(); var lastModifiedDateString =… Continue reading SuiteScript 2.0 Error: no method getTime()
log.error is not a function in SuiteScript
User encounters the error “TypeError log.error is not a function” using SuiteScript 2.0 script This error usually happens if the script has a custom function named log in the script or libraries which it calls. The solution is to find and rename the custom function from “log” to something else like “logExec”. This is not only applicable to… Continue reading log.error is not a function in SuiteScript
Fetch current URL Parameters at Before Load user event in SuiteScript 2.0
The beforeLoad’s entry point gives you an http.ServerRequest via the context.request parameter. function beforeLoad(context) { var parms = context.request.parameters; if(parms) { // do stuff } }
To loop through all item lines when each item line is added
when each item field is added this line field should be updated and also sum of this field should be updated in body field . Implement the client script in sublistChanged trigger: Note: This process will impact the record performance. /** * Function to be executed after sublist is inserted, removed, or edited. * * @param… Continue reading To loop through all item lines when each item line is added
Form.addSublist(options)
This is the method to add a sublist to the custom form. This needs a module called N/ui/serverWidget. This return a serverWidget.Sublist object. It is supported in suitelet script type and user event script types (beforeload). The syntax is as follows: var sublist = form.addSublist({ id: ‘custpage_id’, type: serverWidget.SublistType.INLINEEDITOR, label: ‘Inline editor Sublist’ }); In… Continue reading Form.addSublist(options)
To display banner text in a record using userevent
You can utilize Form.addPageInitMessage(options) to display a message when users access a record or Suitelet. The user event context allows you to manage when the message appears, such as on records in view, create, or edit modes (excluding Suitelets). Module belongs to is N/ui/serverWidget Module Syntax : scriptContext.form.addPageInitMessage({ … Continue reading To display banner text in a record using userevent
N/email module in Suitescript
In this module in suitescript, the syntax is: In the syntax, for the recipients, we can give either the id of the recipient or the email address of the recipient. The author should be the id of the sender. When we give the email in recipient, the email will be sent to them. But when… Continue reading N/email module in Suitescript
Create virtual field to display list of values.
We need to display virtual field on selecting values in a standard field. When “YES ” or “PAO” values are selected in the field USE EXPIRY then we need to display the virtual field. Then select the values from the virtual field and set it in the standard field SHELF LIFE. The fieldChanged() entry point… Continue reading Create virtual field to display list of values.