Articles tagged #SCRIPTING
Articles tagged
#SCRIPTING
Script To Update Multi-Select Field on Save
The article applies to a very specific scenario, but it also demonstrates how to useSuiteScriptto set values on Multi-Select Fields in NetSuite.
Retrieve Values for Multi-Select Field Being Return by nlapiLookupField
Using nlapiLoadRecord then nlobjRecord.getFieldTexts function to retrieve multi-select field selected values will return an array. However this is not the case when you try to retrieve values using nlapiLookupField as it will return String values.
Transfer Values from a Multiselect Field to Another Custom Multi Select Field via Script
To be able to transfer values from a field to another field via script.
Retrieve Values from a Multi-Select Field via Scripting
If multi-select custom field exists on a sales order, the values should be retrieved that are present on an existing record.
List of Time Zone IDs for Scripting
Developers may need to use internal IDs of the time zone depending on their business needs.
Setting Up the SFTP Connector SuiteApp
Make sure the following features are enabled in your account prior to installing the SFTP Connector SuiteApp:
SFTP Connector SuiteApp
The SFTP (Secure File Transfer Protocol) Connector SuiteApp enables you to directly transfer your payment files from NetSuite to your bank servers. You can also download files from your bank server to NetSuite. The SuiteApp establishes an SFTP connection between your NetSuite account and a remote SFTP server.
Setting up an SFTP Transfer
Follow these steps to successfully connect to your SFTP server with SuiteScript:
Supported SuiteScript File Types
SuiteScript has two types of file objects: previously existing files in the NetSuite File Cabinet, and on demand files created using SuiteScript API calls such asfile.create(options)orConnection.download(options).
SuiteScript - Troubleshoot SFTP Connections and Errors
When using the N/sftpSuiteScript 2.0Module in NetSuite, problems may be encountered during the development of Script that will use it. Therefore, is highly recommended to verify all the necessary settings and possible limitations when using this Module. Below are some considerations that need to be taken with the N/sftp Module. These are good practices which we strongly recommend to be taken when using this Module.
SuiteScript Throwing MUTUALLY_EXCLUSIVE_ARGUMENTS Error During SFTP Connection
When there is a use case to send 2 types of authentication at the same time, the below code throws error MUTUALLY_EXCLUSIVE_ARGUMENTS.
Set the Revenue Rec Start Date and Revenue Rec End Dates via Script
This is applicable if you want toset theRevenue Start DateandRevenue End Dateof the item members based on the item group by using it on aUserEventScript.
Update Last Modified and By fields on Custom Record when a Note is Saved using a Script
On a Custom Record, when a Note is created and saved on the Notes tab, User Notes subtab, the Last Modified Date and By fields do not get updated.
Update Lines on Sales Orders using Map/Reduce Script
Mass update lines in a Sales Order which contain a particular value by usingMap/Reducescript.
Get Total Unbilled PO Amount on Vendor Record Using Client Side Script
The total unbilled amount which can be seen in theAmountfield on theVendorrecord is based on the items' total quantity multiplied by their respective amounts. Some use cases permits users to change the rate of each item on theVendor Billrecord which will sometime exceed the totalPurchase Orderamount set in thePurchase Orderrecord.
Set the Class Column on Item Sublist to Mandatory on Company Preferences via Script
User wants to set the Item Sublist columns mandatory to ensure that important information are set on the record (e.g., the Class field).
Dynamically Add Custom Button Using User Event Scripts
A user wants to dynamically add a button in a record using aUser Eventscript.
Call Client Scripts from Workflow
Scenario
Below is an example to demonstrate how this is done. This requires basic SuiteScript and Workflow knowledge.
Solution
- Create a JavaScript file with the following codes:
Note:The above function will be called by the Workflow on Step 5.4.functionsayHello(s){alert('Hello '+s);/* * return true|false line is required to allow/disallow the workflow action to execute. * Condition will treat the function returned false if this line is omitted. * Thus, Workflow Action (e.g. Set Field Value) will not execute */returntrue;} - Navigate toCustomization>Scripting>Scripts>New
- Click on the+logo beside theScript FilePopup List
- Select the JavaScript file on the File Popup Window and click onSave
- UnderDeploymentstab, add the record (Applies Tocolumn) script & workflow must be applied to (For this example,Customerrecord is used and click onSave)
- Navigate toCustomization>Workflows>Workflow>New
- Basic Information:
- Name:EnterName
Example:EnterCustomer Workflow - Record Type:SelectCustomer
- Sub Types:SelectCustomer
- Execute as Admin:EnterCheckmark
- Release Status:SelectReleased
- Name:EnterName
- Event Definition:
- On Create:EnterCheckmark
- On View or Update:EnterCheckmark
- ClickSave
- ClickState 1
- Bottom right corner:ClickNew Action
- ClickSet Field Value
- Basic Information:
- Trigger On:SelectBefore User Edit
- Event Types:SelectCreate
- Context:SelectUser Interface
- Triggering Client Fields:SelectMemo
- Condition:
- SelectFormula
- Formula:EntersayHello(nlapiGetFieldValue('companyname'))
- Triggering Client Fields:SelectMemo
- Parameters:
- Field: SelectAccount
- ClickSave