Articles tagged #SCRIPT
Articles tagged
#SCRIPT
Source Transaction Line Fields from Line on Sales Order onto Body Fields for Linked Work Order using SuiteScript
The User would like to source values of custom Transaction Line Fields from respective lines on a Sales Order onto Body Fields for the Linked Work Order possibly created in the following manner:
Checking Script Update Details in Script File
If we want to check when, what, and who changed a specific script, we may follow the steps below:
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.
Use a Group of Approvers in a Workflow Utilizing a Workflow Action Script
User needs toincorporatea certain group ofApprovers,SupervisorsorEmployeesto aWorkflowto handle the approval process ofa record.
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
Trigger a User Event Script on a Scheduled Script
A user would like to ensure that a User Event Script is triggered when a Scheduled Script is run.
Forecasting Preferences
You can set your company forecast preferences atSetup > Sales & Marketing Automation > Sales Preferences.
Remove Item Options and Add to Cart Button Per Item Record
Currently, un-checking the "Don't Show Price" checkbox in the Web Store tab of an item record, removes the "Add to cart" button per item product page. That will also hide the price of the item. This option will not hide the item options for matrices as well as the custom ones.
SiteBuilder > WSDK > Shopping Cart > Resolve Intermittent Dropping of Items on Google Chrome
When adding unique items into the cart using External Web Sites (WSDK), the shopping cart intermittently drops the previously added items, leaving only the recent added item. Issue is caused by changes to Chrome browser, making cross-site requests have cookies with SameSite=Lax attribute by default when not specified. (additional information can be found here)
Creating Scriptable Templates
You can create scriptable templates with a text/HTML editor outside of NetSuite, or you can use the Text Editor field on the Template subtab of the template record itself. If you create a scriptable template outside of NetSuite, save it as a plain text (.txt) or an HTML (.html or .htm) file.
Resolve Error: "You Have Entered an Invalid Field Value XX for the Following Field: custrecord_8858_process_user" upon Generating Bill Payment File with Custom Role
User with custom role is trying to generate a Bill Payment file in Electronic Payments and receives the following error. This is reproducible when the custom role does not allow access to the Employee's Subsidiary.
Associating Custom Code (Client SuiteScript) Files With Custom Forms
On the Custom Code subtab, define any existing client SuiteScript files to use with this form. When the script's executing function is called, the actions defined within the script (and any built-in NetSuite actions for that form type) are performed.