client suite script
DESCRIPTION
Client SuiteScript Developers GuideTRANSCRIPT
Client SuiteScript Developer’s Guide
Copyright NetSuite, Inc. 2005 All rights reserved.
Client SuiteScript Developer’s Guide
January 18, 2007
This document is the property of NetSuite, Inc., and may not be reproduced in whole or in part without prior written approval of NetSuite, Inc.
Trademarks
NetSuite, NetERP and NetCRM are provided by NetSuite, Inc, and NetSuite is a trademark of NetSuite, Inc.
Oracle is a registered trademark of Oracle Corporation.
Other product names mentioned in this document may be trademarks, servicemarks, or tradenames of their respective companies and are hereby acknowledged.
Contents
Chapter 1 Welcome
In This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Roles & Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2 Using Client SuiteScript
General Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Enabling the Client SuiteScript Feature and Preferences . . . . . . . . . . . . . . . . . . . . . . . . . 4Field Names (IDs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Attaching Client SuiteScripts to Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 PageInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7SaveRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8PostSourcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9ValidateField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9FieldChanged . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Client SuiteScript API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Using the Fire Field Changed Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Working with Line Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Chapter 3 Client SuiteScript Tutorial
Customizing the Page Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Validating Field Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20More Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Triggering Events when a Field is Changed . . . . . . . . . . . . . . . . . . . . . . . . . 21Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Validating a Line Item. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Client SuiteScript Developer’s Guide
Recalculating Field Totals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Prompting before Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Create the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Test the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Chapter 4 Code Names
Code Names by Record Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Case Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Contact Record. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Customer Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Employee Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Event Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Partner Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Task Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Vendor Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Opportunity Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Code Names by Field Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Entity Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38CRM Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Item Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Transaction Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Appendix: Tutorial Code
Client SuiteScript Developer’s Guide
Chapter 1 Welcome
Welcome to NetSuite’s Client SuiteScript feature. With Client SuiteScript you can write custom JavaScript code that performs validations and calculations on forms. You can use custom code in combination with custom fields, forms and records to completely tailor your business management system to your individual business needs.
The purpose of this guide is to introduce you to NetSuite Client SuiteScript tools. It provides step-by-step instructions on how to create and implement Client SuiteScript for your forms as well as real-world examples for how companies use custom code to customize NetSuite accounts for their businesses. Client SuiteScript requires an understanding of JavaScript code and is intended to be used by customers with some advanced programming knowledge only.
Note: When using Client SuiteScript, you will need to create custom fields, forms and records. For more information on the complete customization features available in your NetSuite account, refer to the Customization Guide.
In This GuideThis guide contains the following chapters:
Chapter 1 "Welcome": provides an overview of this guide. Describes which roles in your company can access Client SuiteScript.
Chapter 2 "Using Client SuiteScript": introduces Client SuiteScript and its uses. Provides instructions for turning the feature on. Describes each function and possible API call that can be invoked.
Chapter 3 "Client SuiteScript Tutorial": provides a detailed example of how to use Client SuiteScript to control the behavior of item discounts in a custom Cash Sale Transaction Form.
Chapter 4 "Code Names": provides tables that detail standard field names that can be used in Client SuiteScript.
"Appendix: Tutorial Code": provides the complete code for the example use case created in Chapter 3 "Client SuiteScript Tutorial".
Roles & PermissionsNetSuite provides many standard roles with predefined permissions. A role is a set of permissions that lets customers, vendors, partners and employees access specific areas of your data. Each role grants access at a certain level for each permission.
Access to the Client SuiteScript feature is also controlled using roles and permissions. There are seven standard roles that have access to custom code as outlined in the following table. Refer to this table when assigning employees and vendors the task of implementing Client SuiteScript for the part of NetSuite they or their teams work with.
Client SuiteScript Developer’s Guide
Welcome Roles & Permissions
2
Note: Depending on the product you subscribe to, all of these roles may NOT be available for you to use. Also, in addition to the following standard roles there may be custom roles created with Client SuiteScript permissions assigned to them. To create a custom role, an administrator must go to Setup > Users/Roles > Manage Roles. When customizing a role to add Client SuiteScript capabilities, you must also add permission for customizing entry forms and transaction forms.
Roles Access Level
Administrator FULL
Full Access FULL
Marketing Manager FULL
Marketing Administrator FULL
Sales Manager FULL
Sales Administrator FULL
Support Administrator FULL
Client SuiteScript Developer’s Guide
Chapter 2 Using Client SuiteScript
This section describes the event functions that can be modified and the API calls that can be used in Client SuiteScripts. These scripts are supported across NetSuite versions as long as the procedures and guidelines provided in this guide are adhered to.
Note: NetSuite Client SuiteScript does NOT support JavaScript code using the Document Object Model (DOM) to interact with the objects on the web page.
Currently, you can provide custom JavaScript functions to handle the following events:• Initializing forms• Entering or changing a value in a field (before and after it is entered)• Entering or changing a value in a field that sources another field• Selecting a line item• Adding a line item (before and after it is entered)• Saving a form• Searching for another record• Loading, saving or deleting a record• Sending an email
If desired, functions that save or validate events can abort the action.
General GuidelinesFollowing are some general guidelines to follow when working with NetSuite Client SuiteScript.
Important: During testing of Client SuiteScript, use Ctrl-Refresh to clear your cache and ensure that the latest scripts are being executed.
• Always thoroughly test your code before using on your live NetSuite data.• If the same code is being used across multiple forms, ensure that you test any changes
in the code for each form that the code is associated with.• Ensure that you test your code for the roles that will be using the forms that the code is
associated with. Keep in mind that form definitions may change for different roles such that certain fields may become available or unavailable for certain roles.
• Wherever data may be inconsistent, not available, or invalid for certain functions, ensure that you include proper error handling sequences in your script. For example, if your script requires a field value in order to validate another, ensure that the field value is available.
Client SuiteScript Developer’s Guide
Using Client SuiteScript Getting Started
4
• Organize your code into reusable chunks. Many functions can be used in a variety of forms. Any reusable functions should be stored in a common library file and then called into specific event functions for the required forms as needed.
• Since name values can be changed, ensure that you use static ID values in your API calls where applicable.
• Although you can use any desired naming conventions for functions within your code, it is recommended that the top level functions include an indication of the corresponding NetSuite function. For example, if you are creating a Page Init function, you could name the function pageInit or formAPageInit. If your code is already established, you could simply wrap it with a top level function that has the appropriate naming convention.
• As with any script, ensure that you thoroughly comment your code. This will not only help with debugging and development but will assist NetSuite support in locating problems if necessary.
Getting StartedBefore describing the nuances of creating javascript files for use with your NetSuite forms, review the information provided in this section so that you understand how the code will be implemented.
Enabling the Client SuiteScript Feature and Preferences
Before beginning with Client SuiteScript, you should enable the Client SuiteScript feature and enable the preference that causes NetSuite to display internal IDs.
• Enabling the Client SuiteScript Feature: Go to Setup > Company > Enable Features and check Client SuiteScript on the General tab. Once enabled, the Client SuiteScript feature provides a new folder in the file cabinet at Documents > Files > SuiteScripts. A custom code tab is also available in custom entry and transaction forms. Here you can define which scripts to associated with the current form.
• Displaying Internal IDs (nsKeys): Go to Home > Set Preferences and check Show Internal IDs. When Show Internal IDs is checked, the internalId values for records are displayed in the Internal ID column of record lists.When referencing records in your custom code, always use the internal ID values since the internal IDs are constant but the records themselves may be renamed. For example, to determine if a selection in a drop down is specific value, without worrying if that value has been renamed, refer to the internal ID of the record — not the text name.
Note: The internal ID of a record and a field ID are two different things. Field IDs must be used when calling a field from any custom code API. Field IDs are displayed in the ID column of any lists of fields such as at Setup > Customization > CRM Fields. Record internal IDs are unique IDs associated with a record at creation time. Internal ID values should be used when referencing a specific field value.
Client SuiteScript Developer’s Guide
Using Client SuiteScript Getting Started
5
Field Names (IDs)
Field names (or IDs) must be used when calling a field from any SuiteScript API. Standard field names are provide in Chapter 4 "Code Names". Custom Field IDs are displayed in the ID column of any lists of fields. For example, to obtain the field ID for a specific custom CRM field, go to Setup > Customization > CRM Fields.
Note: When creating custom fields, the custom field ID can be specified or you can accept the default ID assigned by NetSuite. To ensure that the field IDs make sense in the context of your business environment, it is recommended that you always define your own custom field IDs. This will also help to make your custom code more readable. For detailed information on creating custom fields and assigning custom field IDs refer to the Customization User Guide.
Attaching Client SuiteScripts to Forms
After you have created your Client SuiteScript scripts, you need to make the scripts available for custom forms and define which forms will use which functions.
Important: SuiteScripts must have a .js extension.
To attach your script files to a custom form:
1. Upload your scripts to your NetSuite file cabinet.Click Documents > Files > SuiteScripts, navigate to your script file, and click attach.Note: The SuiteScripts folder is provided for convenience; you can store the script files in any location.
2. Go to the desired custom form.Client SuiteScript can only be attached to custom Entry or Transaction forms. Click Setup > Customization > [Form]. Then click edit next to the desire custom form or click Customize next to an existing standard form in order to create a new custom form based on it.Note: For detailed information on creating custom forms, refer to the Customization User Guide.
Client SuiteScript Developer’s Guide
Using Client SuiteScript Functions
6
3. In the custom code tab, select the script file and library script file to associate to the current form.The library script file should contain any commonly used functions whereas the script file should contain functions specific to the current form.
4. Enter the exact name of your function that correlates to each NetSuite function. When a Client SuiteScript script is called for a form function, the actions defined within the SuiteScript file, as well as any NetSuite actions, are performed for the given function. For example, if your form calls a custom PageInit function, the actions defined by that script, as well as any predefined NetSuite actions, are performed prior to the page loading.
FunctionsNetSuite provides several standard functions that are automatically triggered with certain events as outlined in the following table.
Function Parameters Returns Description
PageInit Called when the page is first loaded.
SaveRecord Boolean Called when the user requests the form to be saved. Returns false to reject the operation.
ValidateField* line item type: String; field name: String
Boolean Called when the user changes the value of a field. Returns false to reject the value. This script does NOT apply to dropdown select or check box fields.
FieldChanged* line item type: String; field name: String
Called when a new value for a field is accepted.
PostSourcing type: Stringfield name: String
Called on the FieldChanged event after all slaved fields source.
Line Init line item type: String Called when an existing line is selected in the item machine. The string value returned is always item.
Client SuiteScript Developer’s Guide
Using Client SuiteScript Functions
7
PageInit
The PageInit function is called when the form is first loaded. Some functions that can be performed on PageInit include the following:
• Populate field defaults• Disable or enable fields• Change field availability or values depending on the data available for the record• Add flags to set initial values of fields• Provide alerts where the data being loaded is inconsistent or corrupt• Retrieve user login information and change field availability or values accordingly• Validate that fields required for your custom code (but not necessarily required for the
form) exist
Examples
Set Default Field Values for a Fieldfunction pageInit(){
// is fieldA is either NULL or equal to "valueA"if ((nlapiGetFieldValue('fieldA').length == 0) || (nlapiGetFieldText('fieldA')
== "valueA")){
// then set fieldA to valueBnlapiSetFieldText('fieldA', nlapiGetFieldText('valueB'));
}}
Disable a Fieldfunction pageInit(){
// On init, disable two optional Other fields: fieldA and fieldB.nlapiDisableField('custrecord_other_fieldA', true);nlapiDisableField('custrecord_other_fieldB', true);
}
Display User Profile Informationfunction pageInit(){
// On page init display the currently logged in User's profile information.
// Set variablesvar userName = nlapiGetUser(); // entity id of the current user var userRole = nlapiGetRole(); // id of the current user's role var userDept = nlapiGetDepartment(); // id of the current user's department var userLoc = nlapiGetLocation(); // id of the current user's location
Validate Line line item type: String Boolean Called when a user requests the addition or edit of a line item. Returns false to reject the operation.
Recalc line item type: String Called when a new or edited line has been accepted.
*The ValidateField and FieldChanged scripts require a null line item for body form fields.
Function Parameters Returns Description
Client SuiteScript Developer’s Guide
Using Client SuiteScript Functions
8
// Display informationalert("Current User Information" + "\n\n" +
"Name: " + userName + "\n" + "Role: " + userRole + "\n" + "Dept: " + userDept + "\n" + "Loc: " + userLoc );
}
SaveRecord
The SaveRecord function is called when the user requests the form to be saved. Returns false to reject the operation. Use the Save function to provide alerts to the user before committing the data. If it is necessary for the user to make changes before comitting the data, return false — otherwise display the alert, return true and allow the user to commit the data.
You can also use the SaveRecord function to:• Enable fields that were disabled with other functions• Redirect the user to a specified url
Examples
Requesting Additional Informationfunction SaveRecord(){
// Check to see that fieldA is populated. If not, block the save and warn with a popup.
if (String(nlapiGetFieldValue('fieldA')).length == 0) {
alert("Please provide a value for fieldA");return false;
}alert("Are you sure you want to Save the record?");return true;
}}
Redirect the User to Another Locationfunction saveRecord(type,name){
window.open('https://system.netsuite.com/[url string]');void(0)return true;
}
Client SuiteScript Developer’s Guide
Using Client SuiteScript Functions
9
PostSourcing
(Transaction Forms Only)
The PostSourcing function is called when a field is modified that sources information from another field. Event handlers for this function behave similar to event handlers for the Change Field function except that the function is called only after all sourcing is completed — it waits for any slaved or cascaded field changes to complete before calling the user defined function. Therefore, the event handler is not triggered by field changes for a field that does not have any slaved fields.
If there is at least one field sourced from a drop down (either a built-in sourcing or one created through customization) the post sourcing event is fired. Therefore, if you need to do something based on sourced values, you should do it in PostSourcing rather than from Field Changed.
ValidateField
The ValidateField function is called whenever the user changes the value of a field. This function returns false to reject the value.
Note: This script does NOT apply to dropdown select or check box fields.
Use the ValidateField function to validate field lengths, restrict field entries to a predefined format, restrict submitted values to a specified range, validate the submission against entries made in an associated field,
Examples
Validate Field Lengthsfunction ValidateField(type, name){
// if fieldA is not greater than 5 characters, fail validationif (name == 'fieldA'){
var fieldALength = String(nlapiGetFieldValue('fieldA')).length;
if (fieldALength <= 6){
alert("FieldA must be at least 6 characters.");return false;
}}// Always return true at this level, to continue validating other fieldsreturn true;
}
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
10
FieldChanged
The FieldChanged function is called when a new value for a field is accepted. Use the FieldChanged function to provide the user with additional information based on user input, disable or enable fields based on user input.
Examples
Requesting Additional Informationfunction FieldChanged(type, name){
// Prompt for additional information, based on values already selected. if (name == 'fieldA') && (nlapiGetFieldText('fieldA') == "Other") {
alert("Please provide additional information about fieldA in the text field below.");
}}
Client SuiteScript APIThis section describes the API calls that your Client SuiteScript can invoke to retrieve and modify information on forms. These API calls can only be invoked when an event triggers the custom code functions that have been assigned to the current form. Each call acts on standard or custom fields defined for the current form.
For a complete list of standard fields available on standard NetSuite forms, see “Code Names” on page 27. NetSuite is committed to maintaining these field names across versions. In rare cases where field names must be changed, the name changes will be documented in the release notes for that version of the software.
Important: You can NOT modify the values of the following standard fields with Client SuiteScript.
• Amount• Applied• Unapplied• Total• Exchange Rate• Shipping Cost• Last Modified Date• Creation Date• Return on Investment• Opening Balance
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
11
Function Parameters Description
nlapiGetFieldValue field name: String Retrieves the value of the given field.
nlapiSetFieldValue field name: String; value: String;firefieldchanged: Boolean
Sets the value of the given field. See also “Using the Fire Field Changed Parameter” on page 13
nlapiGetCurrentLineItemValue line item type: String; field name: String
Retrieves the value of the given line-item field before it has been added to the form. Typically used in validate line functions.
nlapiSetCurrentLineItemValue line item type: String; field name: String; value: Stringfirefieldchanged: Boolean
Sets the value of the given line-item field before it has been added to the form. Typically used in validate line functions. See also “Using the Fire Field Changed Parameter” on page 13
nlapiGetLineItemValue line item type: String; field name: String; line index: Integer
Retrieves the value of the given field on the line item at the given index.Note: You cannot set default line item values when the line is not in edit mode.
nlapiSetLineItemValue line item type: String; field name: String; line index: Integer; value: String
Sets the value of the given field on the line item at the given index. Currently, you can use this only to write to description or custom fields. To write to other fields, use the method described at “Example: Adding Line Items to a Transaction” on page 14.
nlapiGetCurrentLineItemIndex line item type: String Retrieves the current index of the line being added or edited. If adding, the function should nlapiGetLineItemCount(type)+1.
nlapiGetLineItemCount line item type: String Retrieves the total number of line items for the given type.
nlapiFormatCurrency amount: Float Formats a floating point value according to the prevailing currency conventions.
nlapiStringToDate string: Date Converts a JavaScript string to a Date according to date formatting conventions.
nlapiDateToString date: Date Converts a JavaScript Date to a string according to date formatting conventions.
nlapiAddDays date: Date; days: Integer Adds a set number of days to a JavaScript date, returning the modified object.
nlapiAddMonths date: Date; months: Integer
Adds a set number of months to a JavaScript date, returning the modified object.
nlapiGetFieldText field name: String Gets the text value of the given selection field.
Important: nlapiGetFieldText can NOT be used on hidden fields.
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
12
nlapiGetCurrentLineItemText line item type: String; field name: Stringfirefieldchanged: Boolean
Gets the text value of the given line-item selection field in the form before it has been added. Typically used in validate line functions. See also “Using the Fire Field Changed Parameter” on page 13
nlapiGetLineItemText line item type: String; field name: String; line index: Integer
Gets the text value of the given selection field on the line item at the given index.
nlapiSetFieldText field name: String; text value: Stringfirefieldchanged: Boolean
Sets the value of the given selection field to the value with the given text. See also “Using the Fire Field Changed Parameter” on page 13
nlapiSetCurrentLineItemText line item type: String; field name: String; text value: String
Sets the value of the given line-item selection field to the value with the given text.
nlapiDisableField field name: String; value: Boolean
Sets the given field to disabled or enabled based on the value (true or false).
nlapiDisableLineItemField line item type: String; field name: String; value: Boolean
Sets the given line item field of the given type to disabled or enabled based on the value (true or false).
nlapiEncrypt Clear Text: String Returns an encrypted string for the given input string.
nlapiGetUser N/A Returns the entity ID of the current user.
nlapiGetRole N/A Returns the ID of the current user’s role.
nlapiGetDepartment N/A Returns the ID of the current user’s department.
nlapiGetLocation N/A Returns the ID of the current user’s location.
nlapiSelectLineItem line item type: Stringline item number: String
Selects an existing line number of a machine. Line number must be between 1 and nlapiGetLineItemCount.
nlapiCommitLineItem line item type: String Commits the current line of a machine type. This is the equivalent of clicking Done for a line item in the UI.
nlapiInsertLineItem line item type: String Inserts a line above the current line of machine.
nlapiRemoveLineItem line item type: String Removes the current line of a machine.
nlapiCancelLineItem line item type: String Cancels any edits to the current line of a machine and reselects the line.
nlapiSelectNewLineItem line item type: String Synonym for nlapiCancelLineItem.
nlapiIsLineItemChanged line item type: String Returns true if the currently selected line of machine has been edited.
nlapiLoadRecord type: record type id: internalID
Loads an existing record.
Function Parameters Description
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
13
Using the Fire Field Changed Parameter
When creating scripts that provide the ability to watch a field for a change, and then write back to the field that just changed, a risk of creating a unending loop exists as follows:
1. The Client SuiteScript code watches for fieldA to change.
2. fieldA changes.
3. The Client SuiteScript writes to fieldA, causing the Field Changed event to fire, returning the code to step 2, and this loop repeats indefinitely.
To prevent this looping behavior, you can set the optional firefieldchanged parameter in your custom code.
The firefieldchanged parameter is available for all write functions. If set to True, the parameter causes any field changed events to fire as normal. This is the default setting. If set to False, field changed events are NOT fired.
Using the new parameter, we can modify the above example to:
1. Custom code watches for fieldA to change.
2. fieldA changes.
3. Client SuiteScript writes to fieldA using firefieldchanged = false, so the Field Changed event does not fire.
The following API calls can set the fireFieldChanged parameter.
nlapiSaveRecord type: record type id: internalID
Saves the current record.
nlapiCreateRecord type: record type Creates a new record instance.
nlapiSearchRecord type: record type searchId: saved search ID
Allows you to search for other records in the system.
nlapiDeleteRecord type: record type id: internalID
Permanently deletes a record from the database.
nlapiSendEmail author: author internalID (must be an employee record)
recipient: recipient internalID
subject: email subject
body: email body
copy[ ] : array of e-mails to copy
blindcopy[ ]: array of emails to blind copy
Generates and sends an email.
Function Parameters Description
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
14
Note: The set line item text and value functions are NOT affected, as these do not currently call field changed after firing.
• nlapiSetFieldValue(field, value, firefieldchanged) • nlapiSetFieldText(field, text, firefieldchanged) • nlapiSetCurrentLineItemValue(type, field, value, firefieldchanged) • nlapiSetCurrentLineItemText(type, field, text, firefieldchanged)
Note: The fireFieldChanged parameter is provided for convenience. To prevent this loop, you could also include code that either checks to ensure that you are not writing the same value to the field or that tracks whether you just wrote to the field.
Working with Line Items
NetSuite provides several functions that can be used to manipulate line items in a machine. You can use these functions to update multiple line items in a machine when a body field is changed or to automate the population of item machine fields when certain conditions exit in the form. Line item functions include:
• nlapiSelectLineItem• nlapiCommitLineItem• nlapiInsertLineItem• nlapiRemoveLineItem• nlapiCancelLineItem• nlapiSelectNewLineItem• nlapiIsLineItemChanged
Important: Once the code associated with a line item function is initiated, mouse events will NOT be responded to until the code is complete. This includes extended delays such as when an alert or prompt is thrown while the line is being manipulated by the code.
Example: Adding Line Items to a Transaction
In order to add a line item to a transaction using custom code, you need to insert the line item and then commit the item in the same script. If you set the item field via nlapiSetCurrentLineItemValue, you can't call nlapiCommitLineItem until the server call for the item information has completed. The only way to know that the server call is complete is to create a postsourcing function that sets a flag.
For example, suppose that you want to insert a shipping line when a user clicks a button. You could attach a function such as insertShippingRate() to that button, which adds an item named “Shipping”, sets its rate, and then commits the line.
function insertShippingRate(){
nlapiSelectNewLineItem('item');/* important so that we know that we were called from insertShippingRate(). */nlapiSetCurrentLineItemValue('item', 'custcolinsertshippingrate', 'T');nlapiSetCurrentLineItemText('item', 'item', 'Shipping');
}
Client SuiteScript Developer’s Guide
Using Client SuiteScript Client SuiteScript API
15
function doPostSourcing(type, fldname){
if ( type == 'item' && fldname == 'item' && nlapiGetCurrentLineItemValue('item', 'custcolinsertshippingrate') == 'T' ){
nlapiSetCurrentLineItemValue('item', 'custcolinsertshippingrate', 'F');nlapiSetCurrentLineItemValue('item', 'rate', '7.50');nlapiCommitLineItem('item');
}}
Client SuiteScript Developer’s Guide
Chapter 3 Client SuiteScript Tutorial
This tutorial provides a detailed example of how to use Client SuiteScript to control the behavior of item discounts in a custom Cash Sale Transaction Form. It is intended for use with NetSuite’s sample company, Wolfe Electronics. You can access Wolfe Electronics by signing up for a Test Drive on the NetSuite Web Site. However, instructions are included to implement the example in an account without Wolfe Electronics data if you wish.
We will start by describing the code to be used when the page first loads, then move on to field changed, validation and page save code. For each section, you may need to create custom elements as described in the Setup sections. If you are familiar with creating custom items, lists and fields, simply refer to the table provided for the required parameters for each element. Otherwise, refer to the Customization User Guide or the online help for detailed instructions. These fields must exist in your NetSuite account prior to using this example. If the items and fields do not exist, you will receive an error when attempting to use your custom cash sale.
Note: Before beginning this tutorial, ensure that you have enabled the Client SuiteScript feature as described in “Enabling the Client SuiteScript Feature and Preferences” on page 4.
Customizing the Page LoadIn the Page Init example, we will cause a 5% transaction discount to be automatically applied to the cash sale price of an item whenever our custom Cash Sale Transaction form is loaded.
Setup
Before creating a script that applies a discount, we must first create a discount item in NetSuite and then use this discount item in our custom code.
Create the Code
Next we will create a javascript file called customCashSales.js and enter the following code. This code sets the discount item field to the value created in Setup.
function samplePageInit(){
nlapiSetFieldValue('discountitem', 144);}
Element Parameters Purpose
Discount Item Item Name/Number: In-store DiscountIncome Account: 4000 SalesRate: 5%Apply Before Sales Tax: No
Defines the discount item that you will refer to in your custom code.
To create, go to Lists > Accounting > Items > New > Discount.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Customizing the Page Load
17
144 refers to the nsKey value of In-Store Discount item created in the preceeding section. You can determine the discount item ID by navigating to the item, and inspecting the id= parameter of the URL or, if you have enabled the display of Internal IDs, the value is displayed in the nsKey column.
Test the Code
Next we will upload the javascript file to NetSuite and apply the code to our custom Cash Sale Transaction form.
To upload the javascript file to NetSuite:
1. Go to Documents > Files > File Cabinet.
2. Select the folder you want to add your file to.
3. At the bottom of the page, select Computer in the Attach From field.
4. Click Browse next to the File field and select the customCashSale.js file you just created.
5. Click Add This File.
To apply the custom code to a transaction form:
1. Go to Setup > Customization > Transaction Forms.
2. Click Customize next to Standard Cash Sale.
3. In the Name field, enter Custom Code Sample.Leave all standard settings the same.
4. Click the Custom Code subtab.
5. In the Script File field, browse to the customCashSale.js file you uploaded to your file cabinet.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Validating Field Values
18
6. In the Page Init Function field, enter samplePageInit.
7. Click Save.
You can now go to Transactions > Sales > Enter Cash Sales to test your custom code. Select the Custom Code Sample form in the Custom Form field on the Cash Sale page.
Notice that the Discount is automatically set to In-Store Discount with the rate at -5%. This cash sale will have the 5% discount applied to it.
Validating Field ValuesOf course, in some cases, there may be customer discounts already assigned for certain customers, in which case we wouldn’t want to automatically assign the lower 5% discount — we will want to consider the customer discount instead. In this section we will create a validation script to ensure that this is the behavior.
Setup
Before creating our code, we will need to setup several customers with custom discounts. The following table lists all of the elements you will need to create in order to do this.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Validating Field Values
19
Create the Code
In this section we will add the validation code to the customCashSales.js file created for the Page Init function.
Note: When applying custom code, you can select up to two javascript files to associate with a given custom form. One file should contain all of the code specific to the current form. The other, library file, should contain any code that may be used across multiple forms. For the purposes of this tutorial, we will include all of the custom code in a single file — customCashSales.js.
Retrieving the Customer Discount
First, we’ll need to create a function that determines whether a customer discount rate has been set. The following code uses nlapiGetFieldText to retrieve the value of the custom transaction body field we created — custbody_cust_discount. If it exists, we convert the value to a negative number to ensure that the total is decreased by the specified amount and the value is then returned.
Element Parameters Purpose
5 Discount Items Item Name/Number: 10%*Income Account: 4000 SalesRate: 10%*Apply Before Sales Tax: No
And four additional discount items with the Item Name/Number and Rate fields to 15%, 20%, 25% and 30% respectively
Defines the discount items that you will be able to set for any customers.
To create, go to Lists > Accounting > Items > New > Discount.
Custom List Name: Customer DiscountsValues: 10%, 15%, 20%, 25%, 30%
Defines the selection list of discount items.
To create, go to Setup > Customization > Lists > New.
Entity Field Description: Customer DiscountID: _customer_discountType: List/RecordList/Record: Customer DiscountsApplies To: Customer:JobSubtab: General
Sources the list just created.
To create, go to Setup > Customization > Entity Fields > New.
Transaction Body Field
Description: Cust. DiscountID: _cust_discountType: List/RecordList/Record: Customer DiscountsApplies To: SaleSubtab: MainDisplay Type: DisabledSource LIst: EntitySource From: Customer Discount
To create, go to Setup > Customization > Transaction Body Fields > New.
Customer Records
Set a discount to various customers.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Validating Field Values
20
function calcCustomerDiscountRate(){
if( !isNaN(parseFloat(nlapiGetFieldText('custbody_cust_discount'))) )return ((parseFloat(nlapiGetFieldText('custbody_cust_discount'))) * -1);
elsereturn 0;
}
Determining Which Discount to Use
Next, we’ll want to make sure that the Page Init function does not cause the discount to be set to 5% if a customer already has a pre-defined higher discount rate.
1. Create a new function.function sampleValidateField(type, name){
2. Set the variablesvar useCustomerDiscount = true;var instore_discount = -5;var cust_discount = calcCustomerDiscountRate();
3. Determine if In-Store discount is higher than the customer discount and return an alert that allows you to choose whether to accept the higher value.
if ( instore_discount <= cust_discount ){
useCustomerDiscount = false;}if( useCustomerDiscount ){
alert("custbody_cust_discount: '" + nlapiGetFieldText('custbody_cust_discount') + "'");nlapiSetFieldText('discountitem', nlapiGetFieldText('custbody_cust_discount'));
}else{
nlapiSetFieldText('discountitem', "In-store Discount");}
4. Close the function.}
Test the Code
Now upload the modified customCashSale.js file to the file cabinet and then assign the sampleValidateField function for the Validate Field function on the Custom Code Sample form.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Triggering Events when a Field is Changed
21
Now when we enter a cash sale using the Custom Code Sample form, if a customer is selected that has a pre-defined discount higher than the In-store discount set by the Page Init function, then the In-store discount is NOT used.
More Validation
This is a very simple case. In reality, we’d need to add some further validation to ensure that the field types are in the correct format and we may want to check for other discount restrictions, etc. The complete code included in the appendix, Appendix: Tutorial Code includes javascript validation for the following:
• If the transaction discount is changed to a rate greater than $50 or 30%, a box pops up asking for confirmation of manager approval for the discount. The user can choose to keep the current discount or abort the discount. If the discount is aborted, a message is displayed to notify the user that the discount level is not approved and it will be reset.
• If more than 20 of any one item is added to the transactions, a box pops up asking if you are sure you want to add the item. The user can choose to add the items or return to the item list without adding the items.
Triggering Events when a Field is ChangedIn the Field Changed example, we will cause a popup box display that indicates if a customer has had order problems in the past and reminds the user to verify all items before submitting the order.
Setup
This script requires the creation of custom entity and transaction body fields.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Triggering Events when a Field is Changed
22
Create the Code
In this section we will add the field changed code to the customCashSales.js file.
1. First, we will set this code to fire on any change to the transaction body field created during Setup.
function sampleFieldChanged(type, name){if (name == 'custbody_had_order_problems'){
Remember, the custbody_had_order_problems is sourced from the entity field selected. Therefore, this code will be executed each time a new customer is selected in the form. Since the custbody_had_order_problems field is locked, it can NOT be edited directly.
2. Next, we’ll check the value of the checkbox field and if set to T, display an alert.if ( (nlapiGetFieldValue('custbody_had_order_problems') == 'T') &&
(nlapiGetFieldText('entity')) ){
alert("This customer has had order problems previously. Be sure to verify all items with the customer before submitting the order.");return true;
}
3. Finally, we will close the function without causing any additional change. }return true;}
Test the Code
Upload the modified customCashSale.js file to the file cabinet and then assign the sampleFieldChanged function for the Field Change Validation function on the Custom Code Sample form.
Element Parameters Purpose
Entity Field Description: Past Order ProblemsSubtab: GeneralID: _had_order_problemsApplies To: Customer:Job
To create, go to Setup > Customization > Entity Field > New.
Transaction Body Field
Description: Past Order ProblemsType: Check BoxSource List: EntitySubtab: MainDisplay Type: LockedID: _had_order_problemsApplies To: Sale
To create, go to Setup > Customization > Transaction Body Field > New.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Validating a Line Item
23
Now when we enter a cash sale using the Custom Code Sample form, if a customer is selected where Past Order Problems checkbox is enabled, an alert is displayed.
Validating a Line ItemIn the Validate Line example, we will include validation that prevents the addition of a service line item without a service employee being chosen for that line.
Setup
This script requires the creation of a custom entity and custom transaction column field.
Create the Code
Again, we will modify the customCashSale.js file to add the following code. The code simply checks the value of the custcol_service_rep custom field whenever a custcol_service_item item is selected. If the value is T, then an alert is displayed and the event is aborted. The user is forced to first select a service rep before entering any line items.
function sampleValidateLine(type){
Element Parameters Purpose
Entity Field Description: Service RepType: Check BoxSubtab: Human ResourcesApplies To: Employee
Provides a checkbox on employee records where you can define an employee as a service rep.
To create, go to Setup > Customization >Entity Field > New.
Transaction Column Field
Description: Service RepType: List/RecordList/Record: EmployeeID: _service_repApplies To: Sale ItemFilter Using: Service RepIs Checked: True
To create, go to Setup > Customization > Transaction Column Field > New.
Employee Records
Assign various employees as service reps.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Recalculating Field Totals
24
if ( (nlapiGetCurrentLineItemValue('item', 'custcol_service_item') == 'T') &&(!nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) )
{alert("You must choose a Service Rep for this service item.");return false;
}return true;
}
Test the Code
Upload the modified customCashSale.js file to the file cabinet and then assign the sampleValidateLine function for the Validate Line function on the Custom Code Sample form.
Now when we enter a cash sale using the Custom Code Sample form, if a service line item is selected when a sales rep has not been assigned, the user is forced to return and select a sales rep for the customer before selecting any service items.
Recalculating Field TotalsIn the Recalc example, we will determine if items added to the cash sale are service items. If the item is a service, the sales price is added to the service bookings field.
Setup
This script requires the creation of a custom item field, transaction column field and transaction body field.
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Recalculating Field Totals
25
Create the Code
Again, we will modify the customCashSale.js file to add the following code.function sampleRecalc(type){
var total = 0;for ( i = 1; i <= nlapiGetLineItemCount('item'); i++){
var item_amount = parseFloat(nlapiGetLineItemValue('item', 'amount', i));if (nlapiGetLineItemValue('item', 'custcol_service_item', i) == 'T'){
total += item_amount;}
}nlapiSetFieldValue('custbody_service_bookings', nlapiFormatCurrency(total));
}
Test the Code
Upload the modified customCashSale.js file to the file cabinet and then assign the sampleRecalc function for the Validate Line function on the Custom Code Sample form.
Element Parameters Purpose
Item Field Description: Service ItemType: Check BoxSubtab: BasicID: _service_itemApplies To: ServiceDefault Checked: True
To create, go to Setup > Customization > Item Field > New.
Transaction Body Field
Description: Service BookingsType: CurrencySubtab: MainDisplay Type: LockedID: _service_bookingsApplies To: Sale
To create, go to Setup > Customization > Transaction Body Field > New.
Item Records Designate various existing items as service items.
Any new service items created are automatically marked as service items..
Client SuiteScript Developer’s Guide
Client SuiteScript Tutorial Prompting before Save
26
Now when we save a cash sale using the Custom Code Sample form, any service items amounts are added to the service bookings field.
Prompting before SaveIn the Save example, we will cause a pop-up box to display when a record is saved that prompts the user with “Are you sure you want to save this record?” The code will execute the save if the user clicks OK and abort the save if the user clicks Cancel.
Note: No record customization (setup) is required for this script to work properly.
Create the Code
Again, we will modify the customCashSale.js file to add the following code. This simple script returns a dialog box prompting the user to confirm the save.
function sampleSaveRecord(){
return confirm("Are you sure you want to save this record?");}
Test the Code
Upload the modified customCashSale.js file to the file cabinet and then assign the sampleSaveRecord function for the Save Record function on the Custom Code Sample form.
Now when we save a cash sale using the Custom Code Sample form, a confirmation prompt is returned.
Client SuiteScript Developer’s Guide
Chapter 4 Code Names
The tables in this chapter detail standard field names that can be used in custom code. You can reference the table with names listed by record type or by field type.
Note: When referenced in Client SuiteScript, field names are case sensitive. Also, the Field Name column in the following tables refers the standard field name NetSuite uses to define the given field. This name may differ in your account if the name has been customized.
Code Names by Record Type:• Case Record• Contact Record• Customer Record• Employee Record• Event Record• Partner Record• Task Record• Vendor Record• Opportunity Record
Code Names by Field Type:• Entity Fields• CRM Fields• Item Fields• Transaction Fields
You can also find the Custom Code ID for any standard or custom field in NetSuite by viewing the page source of any form that displays the desired field.
To find any Client SuiteScript ID for a Field in NetSuite:
1. Display the form that contains the standard or custom field ID you need in edit mode.You can display a form in edit mode by editing an existing record or creating a new record. For example, to find the Client SuiteScript ID for a field on an Opportunity form, display the list of Opportunities and click Edit next to an Opportunity record.
2. Copy the Field name. Highlight the field text and press CTRL + C .
3. Right click in the form and select View Source (or View Page Source).
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
28
4. Find the Field name in the source.Press CTRL + F (Find) and then CTRL + V (Paste) and hit Return.
5. Examine the Anchor tag for that Field. The anchor tag contains the Custom Code ID for the field.
For example:
To find the Custom Code ID for the Win/Loss Reason field in an Opportunity form, navigate to the opportunity form (in edit mode), and find the Win/Loss Reason field in the page source. The anchor tag is as follows:
<A class='smalltextnolink' tabindex=-1 title="What's this?" href='javascript:void("help")'style='cursor:help'onclick="return nlFieldHelp(19,'TRAN_OPPRTNTY','winlossreason', this)"onkeypress="event.cancelBubble = true; return true;" onmouseover="this.className='smalltextul'; returntrue;" onmouseout="this.className='smalltextnolink'; ">Win/Loss Reason</A>
Therefore, the Custom Code ID for the Win/Loss Reason field is winlossreason.
Code Names by Record Type
Case Record
Code Name Field Name Location
assigned Assigned main
casenumber Case Number main
category Category main
company Company main
contact Contact main
createddate Creation Date main
customform Custom Form main
email E-mail main
emailemployees E-Mail Employees main
emailform E-mail reply main
escalationmessage Escalation Message escalation
helpdesk Help Desk main
inboundemail Inbound E-mail main
incomingmessage Incoming Message main
internalonly Internal Only main
isinactive Inactive main
issue Issue main
item Item main
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
29
Contact Record
lastmessagedate Last Message Date main
lastmodifieddate Last Modified Date main
origin Origin main
outgoingmessage Outgoing Message main
phone Phone main
priority Priority main
serialnumber Serial Number main
startdate Start Date main
starttime Start Time main
status Status main
title Title main
Code Name Field Name Location
altemail Alt. E-mail general
assistant Assistant general
assistantphone Assistant Phone general
availableoffline Always Available Offline main
category Category main
comments Comments general
company Company main
customform Custom Form main
email E-Mail general
entityid Name/ID main
fax Fax general
firstname First Name general
homephone Home Phone general
image Image general
isinactive Inactive main
isprivate Private main
lastname Last Name general
middlename Middle Name general
mobilephone Mobile Phone general
officephone Office Phone general
phone Phone general
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
30
Customer Record
salutation Mr./Ms... general
supervisor Supervisor general
supervisorphone Supervisor Phone general
title Job Title general
unsubscribe Unsubscribe general
Code Name Field Name Location
accessrole Role access
accountnumber Account financial
aging Aging financial
altphone Alt. Phone general
availableoffline Always Available Offline main
balance Balance financial
category Category general
clickstream Click-Stream (1st Visit) web
comments Comments general
companyname Company Name general
creditlimit Credit Limit financial
currency Currency financial
customform Custom Form main
datecreated Date Created general
email E-Mail general
enddate End Date financial
entityid Name/ID main
entitystatus Status main
fax Fax general
firstvisit Date of First Visit web
giveaccess Has Access access
image Image general
isinactive Inactive main
keywords Search Engine Keywords (1st Visit)
web
language Language general
lastpagevisited Last Page Visited web
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
31
Employee Record
lastvisit Date of Last Visit web
leadsource Lead Source general
openingbalance Opening Balance financial
parent Parent main
partner Partner general
password Password access
phone Phone general
prefccprocessor Pref. CC Processor financial
pricelevel Price Level financial
printoncheckas Print On Check As general
probability Probability main
referrer Referrer (1st Visit) web
reminderdays Reminder Days financial
resalenumber Resale Number financial
salesrep Sales Rep general
sendemail Send Notification E-mail access
shippingitem Shipping Item financial
startdate Start Date financial
taxable Taxable financial
taxitem Tax Item financial
terms Terms financial
territory Territory general
unsubscribe Unsubscribe general
url Web Address general
vatregnumber VAT Registration Nº financial
visits Number of Visits web
weblead Web Lead general
Code Name Field Name Location
accountnumber Account general
aeic AEIC payfed
aliennumber Alien Number hrworkstatus
allowance Allowance payfed
approvallimit Approval Limit hr
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
32
approver Approver hr
authworkdate Authorized to work until hrworkstatus
billingclass Billing Class general
birthdate Birth Date hr
class Class general
comments Comments general
customform Custom Form main
degree Degree hreducation
degreedate Date Conferred hreducation
department Department general
directdeposit Use Direct Deposit dd
education Level of Education hreducation
email E-Mail general
employeestatus Employee Status hr
employeetype Type hr
entityid Name/ID main
ethnicity Ethnicity hrpersonal
extra Extra Withholding payfed
fax Fax general
fedstatus Filing Status payfed
fedunemp Federal Unemployment payfed
fedwith Federal Withholding payfed
firstname First Name general
gender Gender hrpersonal
giveaccess Has Access access
hasofflineaccess Offline Client Access access
hiredate Hire Date hr
homephone Home Phone general
i9verified I-9 Verified hrworkstatus
image Image general
inheritiprules Inherit IP Rules from Company
access
initials Initials general
ipaddressrule IP Address Restriction access
isinactive Inactive main
issalesrep Sales Rep hr
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
33
issueusertype Issue User Type hr
issupportrep Support Rep hr
jobdescription Job Description hr
lastname Last Name general
lastpaiddate Last Paid date payroll
lastreviewdate Last Review Date hr
location Location general
maritalstatus Marital Status hrpersonal
medicare Medicare payfed
middlename Middle Name general
mobilephone Mobile Phone general
nextreviewdate Next Review Date hr
officephone Office Phone general
password Password access
payfrequency Pay Frequency payroll
phone Phone general
releasedate Release Date hr
residentstatus Resident Status hrworkstatus
salutation Mr./Ms... general
sendemail Send Notification E-mail access
socialsecurity Social Security payfed
socialsecuritynumber Social Security hr
supervisor Supervisor hr
template Template main
terminationbydeath Termination Due To Death hr
title Job Title hr
unsubscribe Unsubscribe general
usetimedata Use Time Data payroll
visaexpdate Visa Expiration Date hrworkstatus
visatype Visa Type hrworkstatus
w4completed W4 Completed payfed
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
34
Event Record
Partner Record
Code Name Field Name Location
accesslevel Access Level main
customform Custom Form main
endtime End Time main
location Location main
message Message main
organizer Organizer main
reminderminutes Minutes main
remindertype Reminder Type main
startdate Start Date main
starttime Start Time main
status Status main
title Title main
transaction Opportunity main
Code Name Field Name Location
accessrole Role
category Category general
comments Comments general
companyname Company Name general
customform Custom Form main
email E-Mail general
entityid Name/ID main
fax Fax general
giveaccess Has Access access
image Image general
isinactive Inactive main
partnercode Partner Code
password Password access
phone Phone general
printoncheckas Print On Check As general
sendemail Send Notification E-mail access
subpartnerlogin Can give login access To Subpartners
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
35
Task Record
Vendor Record
taxidnum Tax ID financial
unsubscribe Unsubscribe general
url Web Address general
Code Name Field Name Location
accesslevel Access Level main
assigned Assigned main
completeddate Date Completed main
customform Custom Form main
enddate End Date main
message Message main
order Order main
owner Owner main
priority Priority main
sendemail Send E-mail main
startdate Start Date main
status Status main
title Title main
transaction Opportunity main
Code Name Field Name Location
accountnumber Account financial
altphone Alt. Phone general
balance Balance financial
category Category general
comments Comments general
companyname Company Name general
creditlimit Credit Limit financial
currency Currency financial
customform Custom Form main
email E-Mail general
entityid Name/ID main
expenseaccount Default Expense Account financial
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
36
Opportunity Record
fax Fax general
giveaccess Has Access access
image Image general
is1099eligible 1099 Eligible financial
isaccountant Make this my FREE accountant
access
isinactive Inactive main
legalname Legal Name financial
openingbalance Opening Balance financial
password Password access
phone Phone general
prefccprocessor Pref. CC Processor financial
printoncheckas Print On Check As general
sendemail Send Notification E-mail access
taxidnum Tax ID financial
terms Terms financial
unsubscribe Unsubscribe general
url Web Address general
vatregnumber VAT Registration Nº financial
Code Name Field Name Location Available For
actionitem Action Item main screen
altsalesamt Alt.Sales screen
amount Amount screen
availableoffline Always Available Offline main screen
balance Balance main off
billaddress Bill To address both
class Class off
class Class main screen
currencyname Currency items screen
customform Custom Form main screen
department Department off
department Department main screen
description Description screen
entity Entity main screen
Code Name Field Name Location
Client SuiteScript Developer’s Guide
Code Names Code Names by Record Type
37
entitystatus Entity Status main screen
exchangerate Exchange Rate items screen
expectedclosedate Exp. Close Date main screen
forecasttype Forecast Type main screen
grossamt Gross Amt both
item Item screen
job Job off
leadsource Lead Source main screen
location Location off
location Location main screen
memo Memo main screen
pagenumber Page Number print
partner Partner main screen
probability Probability main screen
projaltsalesamt Alt.Sales Amount main screen
projectedtotal Projected Total main screen
quantity Quantity screen
quantityavailable Available off
quantityonhand On Hand off
rate Rate screen
salesrep Sales Rep main screen
serialnumbers Serial Numbers screen
shipaddress Ship To address both
tax1amt Tax Amt both
taxcode Tax Code screen
taxrate1 Tax Rate both
terminmonths Revenue Recognition Term in Months
off
title Title main screen
trandate Date main screen
tranid Doc. No. main screen
units Units screen
vatregnum Tax Id main both
weightedtotal Weighted Total main screen
winlossreason Win/Loss Reason main screen
Code Name Field Name Location Available For
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
38
Code Names by Field Type
Entity Fields
Code Name Field Name Customer Job Vendor Partner Employee Contact
accessrole Role access access
accountnumber Account financial financial general
aeic AEIC payfed
aging Aging financial
aliennumber Alien Number hrworkstatus
allowance Allowance payfed
altcontact Alt. Contact
altemail Alt. E-mail general
altphone Alt. Phone general general general
approvallimit Approval Limit hr
approver Approver hr
assistant Assistant general
assistantphone Assistant Phone
general
authworkdate Authorized to work until
hrworkstatus
availableoffline Always Available Offline
main main
balance Balance financial financial
billingclass Billing Class general
birthdate Birth Date hr
category Category general general general general main
class Class general
clickstream Click-Stream (1st Visit)
web
comments Comments general general general general general general
company Company main
companyname Company Name
general general general general
creditlimit Credit Limit financial financial
currency Currency financial financial
customform Custom Form main main main main main main
datecreated Date Created general general
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
39
degree Degree hreducation
degreedate Date Conferred hreducation
department Department general
directdeposit Use Direct Deposit
dd
education Level of Education
hreducation
email E-Mail general general general general general general
employeestatus Employee Status
hr
employeetype Type hr
enddate End Date financial financial
entityid Name/ID main main main main main main
entitystatus Status main main
estimatedcost Estimated Cost financial
estimatedrevenue Estimated Revenue
financial
ethnicity Ethnicity hrpersonal
expenseaccount Default Expense Account
financial
extra Extra Withholding
payfed
fax Fax general general general general general general
fedstatus Filing Status payfed
fedunemp Federal Unemployment
payfed
fedwith Federal Withholding
payfed
firstname First Name general general
firstvisit Date of First Visit
web
gender Gender hrpersonal
giveaccess Has Access access access access access
hasofflineaccess Offline Client Access
access
hiredate Hire Date hr
homephone Home Phone general general
Code Name Field Name Customer Job Vendor Partner Employee Contact
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
40
i9verified I-9 Verified hrworkstatus
image Image general general general general general general
inheritiprules Inherit IP Rules from Company
access
initials Initials general
ipaddressrule IP Address Restriction
access
is1099eligible 1099 Eligible financial
isaccountant Make this my FREE accountant
access
isinactive Inactive main main main main main main
isprivate Private main
issalesrep Sales Rep hr
issueusertype Issue User Type hr
issupportrep Support Rep hr
jobdescription Job Description
hr
jobtype Job Type general
keywords Search Engine Keywords (1st Visit)
web
language Language general general
lastname Last Name general general
lastpagevisited Last Page Visited
web
lastpaiddate Last Paid date payroll
lastreviewdate Last Review Date
hr
lastvisit Date of Last Visit
web
leadsource Lead Source general
legalname Legal Name financial
location Location general
maritalstatus Marital Status hrpersonal
medicare Medicare payfed
middlename Middle Name general general
mobilephone Mobile Phone general general
Code Name Field Name Customer Job Vendor Partner Employee Contact
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
41
nextreviewdate Next Review Date
hr
officephone Office Phone general general
openingbalance Opening Balance
financial financial financial
parent Parent main main
partner Partner general
partnercode Partner Code main
password Password access access access access
payfrequency Pay Frequency payroll
percentcomplete Percent Complete
financial
phone Phone general general general general general general
prefccprocessor Pref. CC Processor
financial financial
pricelevel Price Level financial
printoncheckas Print On Check As
general general general
probability Probability main
projectedenddate Projected End Date
financial
referrer Referrer (1st Visit)
web
releasedate Release Date hr
reminderdays Reminder Days financial
resalenumber Resale Number financial
residentstatus Resident Status hrworkstatus
salesrep Sales Rep general
salutation Mr./Ms... general general
sendemail Send Notification E-mail
access access access access
shippingitem Shipping Item financial
socialsecurity Social Security payfed
socialsecuritynumber
Social Security hr
startdate Start Date financial financial
Code Name Field Name Customer Job Vendor Partner Employee Contact
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
42
CRM Fields
subpartnerlogin Can give login access To Subpartners
access
supervisor Supervisor hr general
supervisorphone Supervisor Phone
general
taxable Taxable financial
taxidnum Tax ID financial general
taxitem Tax Item financial
template Template main
terminationbydeath
Termination Due To Death
hr
terms Terms financial financial
territory Territory general
title Job Title hr general
unsubscribe Unsubscribe general general general general general
url Web Address general general general
usetimedata Use Time Data payroll
vatregnumber VAT Registration Nº
financial financial
visaexpdate Visa Expiration Date
hrworkstatus
visatype Visa Type hrworkstatus
visits Number of Visits
web
w4completed W4 Completed payfed
weblead Web Lead general
Code Name Field Name Customer Job Vendor Partner Employee Contact
Code Name Field Name Task Event Case Campaign Solution Call
accesslevel Access Level main main main
assigned Assigned main main main
casenumber Case Number main
category Category main
company Company main
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
43
completeddate Date Completed main main
contact Contact main
convcostpercustomer Cost Per Customer Conversion
stat
cost Cost main
costpercustomer Cost Per Customer Acquisition
stat
createddate Creation Date main
customform Custom Form main main main main main main
displayonline Display Online main
email E-mail main
emailemployees E-Mail Employees main
emailform E-mail reply main
enddate End Date main main
endtime End Time main
escalationmessage Escalation Message escalation
expectedrevenue Expected Revenue main
helpdesk Help Desk main
inboundemail Inbound E-mail main
incomingmessage Incoming Message main
internalonly Internal Only main
isinactive Inactive main main main
issue Issue main
item Item main main
lastmessagedate Last Message Date main
lastmodifieddate Last Modified Date main
location Location main
longdescription Long Description detail
message Message main main main main main
order Order main
organizer Organizer main
origin Origin main
outgoingmessage Outgoing Message main
owner Owner main main main
phone Phone main main
priority Priority main main main
Code Name Field Name Task Event Case Campaign Solution Call
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
44
Item Fields
profit Profit stat
reminderminutes Minutes main
remindertype Reminder Type main
roi Return on Investment
stat
sendemail Send E-mail main main
serialnumber Serial Number main
solutioncode Solution Code main
startdate Start Date main main main main main
starttime Start Time main main
status Status main main main main main
title Title main main main main main main
transaction Opportunity main main main
Code Name Field Name Task Event Case Campaign Solution Call
Code Name Field Name Inventory Part
Non-Inventory Part
Group/Kit/Assembly
Discount/Markup Payment Description/
Subtotal
account Account basic basic
amortizationperiod
Amortization Period
basic
amortizationtemplate
Amortization Template
basic
assetaccount Asset Account
basic basic
availabletopartners
Available To Adv. Partners
main main main main main main
billingschedule
Billing Schedule
basic basic basic
class Class main main main main main main
cogsaccount COGS Account
basic basic
cost Purchase Price
inventory basic inventory
costingmethod
Costing Method
basic basic
countryofmanufacture
Country of Manufacture
basic basic basic
currency Currency basic basic basic
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
45
customform Custom Form main main main main main main
daysbeforeexpiration
Days Before Expiration
basic
deferralaccount
Deferral Account
basic
deferredrevenueaccount
Deferred Revenue Account
basic basic basic
demandmodifier
Estimated Demand Change
inventory inventory
department Department main main main main main main
description Description basic basic basic basic
displayname Display Name
main main main main main
expenseaccount
Expense Account
basic
featureddescription
Featured Description
specials specials specials
froogleproductfeed
Froogle Product Feed
store store store
handlingcost Handling Cost
basic basic basic
incomeaccount
Income Account
basic basic basic
internalid Internal ID store store store
isdonationitem
Variable Amount
store store store
isdropshipitem
Drop Ship Item
basic basic
isfeatured Featured Item
specials specials specials
isinactive Inactive main main main main main main
isonline Display in Web Site
main main main
ispretax Apply Before Sales Tax
basic
istaxable Taxable basic basic basic
isvsoebundle Is VSOE Bundle?
main
Code Name Field Name Inventory Part
Non-Inventory Part
Group/Kit/Assembly
Discount/Markup Payment Description/
Subtotal
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
46
itemid Item Name/Number
main main main main main main
leadtime Lead Time inventory inventory
liabilityaccount
Liability Account
basic
location Location main main main main main main
manufacturer
Manufacturer
basic basic basic
metataghtml Meta Tag HTML
store store store
mpn MPN basic basic basic
nextagcategory
NexTag Category
store store store
nextagproductfeed
NexTag Product Feed
store store store
numofalloweddownloads
Number of Allowed Downloads
basic
offersupport Offer Support
main main main
onspecial On Special specials specials specials
overallquantitypricingtype
Calculate Quantity Discounts
pricing pricing pricing
pagetitle Page Title store store store
parent Subitem Of main main main main
paymentmethod
Payment Method
basic
preferredlocation
Preferred Location
inventory inventory
preferredstocklevel
Preferred Stock Level
inventory inventory
pricinggroup Pricing Group
pricing pricing pricing
printitems Print Items main
purchasedescription
Purchase Description
basic basic
purchasetaxcode
Purchase Tax Code
basic basic
Code Name Field Name Inventory Part
Non-Inventory Part
Group/Kit/Assembly
Discount/Markup Payment Description/
Subtotal
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
47
quantityavailable
Quantity Available
inventory inventory
quantitybackordered
Quantity Back Ordered
inventory inventory
quantitycommitted
Quantity Committed
inventory inventory
quantityonhand
Quantity On Hand
inventory inventory
quantityonorder
Quantity On Order
inventory inventory
quantitypricingschedule
Quantity Pricing Schedule
pricing pricing pricing
rate Rate basic basic basic basic
relateditemsdescription
Related Items Description
relitems relitems relitems
reorderpoint Reorder Point
inventory inventory
residual Residual basic
revrecschedule
Revenue Recognition Template
basic basic basic
safetystocklevel
Safety Stock Level
inventory inventory
salesdescription
Sales Description
basic basic
salestaxcode Sales Tax Code
basic basic basic basic
seasonaldemand
Seasonal Demand
inventory inventory
serialnumbers
Serial Numbers
inventory inventory
shippingcost Shipping Cost
basic basic basic
shoppingcategory
Shopping Category
store store store
shoppingproductfeed
Shopping Product Feed
store store store
shopzillacategoryid
Shopzilla Category ID
store store store
Code Name Field Name Inventory Part
Non-Inventory Part
Group/Kit/Assembly
Discount/Markup Payment Description/
Subtotal
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
48
Transaction Fields
For convenience, the transaction fields information has been split into multiple tables, each table defining the fields available for a specific set of records as follows:
• Table 1 — Remittance Slip, Return Request-Credit, Return Request-Cash, Online Order-Invoice, Online Order-Cash Sale
shopzillaproductfeed
Shopzilla Product Feed
store store store
specialsdescription
Specials Description
specials specials specials
stockdescription
Stock Description
basic basic basic
storedescription
Store Description
store store store
storedetaileddescription
Detailed Description
store store store
storedisplayimage
Item Display Image
store store store
storedisplayname
Store Display Name
store store store
storedisplaythumbnail
Item Display Thumbnail
store store store
storeitemtemplate
Item Drilldown Template
store store store
totalvalue Total Value inventory inventory
unitstype Units Type basic basic basic
usemarginalrates
Use Marginal Rates
pricing pricing pricing
vendor Preferred Vendor
basic basic
vendorname Vendor Name
main main main main
vsoedeferral Deferral vsoepricing vsoepricing vsoepricing
vsoedelivered
Delivered vsoepricing vsoepricing vsoepricing
vsoepermitdiscount
Permit Discount
vsoepricing vsoepricing vsoepricing
vsoeprice VSOE Price vsoepricing vsoepricing vsoepricing
weight Item Weight basic basic basic
Code Name Field Name Inventory Part
Non-Inventory Part
Group/Kit/Assembly
Discount/Markup Payment Description/
Subtotal
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
49
• Table 2 — Opportunity, Drop Ship Purchase Order, Shipping Label, Return Form, Statement
• Table 3 — Packing Slip, Picking Ticket, Return Authorization - Cash, Return Authorization - Credit, Sales Order - Progress Billing
• Table 4 — Progress Invoice, Sales Order - Cash Sale, Sales Order - Invoice, Canada Finance Charge, Service Invoice
• Table 5 — Product Invoice, Professional Invoice, Credit Memo, Cash Sale• Table 6 — Cash Refund, Estimate, Purchase Order, Finance Charge
Note: For line items on transactions, you may only set values for line items in edit mode.
Table 1
Code Name Field Name Tab Remittance Slip
Return Request - Credit
Return Request - Cash
Online Order - Invoice
Online Order - Cash Sale
accountnumber Acct. No. off off off off
amount Amount both both both both
amountdue Amount Due Print
amountpaid Amount Paid Print
balance Balance main Off
barcode Barcode Print
billaddress Bill To address Both Both Both Both
billingschedule Bill. Sched. main Off Off
billingschedule Billing Schedule Off Off
ccinfo Credit Card Info Print
ccnumber Credit Card # payment Both Both
companyaddress Company Address Print Print Print Print Print
companyfednum Business Number Off Off Off Off
companylogo Company Logo Print Print Print Print
companyname Company Name Print Off Off Off Off
companyphone Company Phone Off Off Off Off
companyurl Company URL Off Off Off Off
createpo Create PO Off Off
creditcardprocessor Credit Card Processor
payment Screen Screen
currencyname Currency items Screen Screen Screen Screen
customername Customer Print
description Description Both Both Both Both
discountitem Discount items Both Both
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
50
enddate End Date main Off Off
entity Entity main Screen Screen Screen Screen
exchangerate Exchange Rate items Screen Screen Screen Screen
excludecommission Exclude Commissions
main Off Off Off Off
fob FOB shipping Off Off
formtitle Form Title Print Print Print Print Print
grossamt Gross Amt Both Both Both Both
istaxable Tax Both Both Both Both
istaxable Taxable items Screen Screen Screen Screen
item Item Both Both Both Both
job Job Off Off Off Off
memo Memo main Screen Screen Screen Screen
options Options Both Both Both Both
otherrefnum Ref. No. main Print Print Print Print
pagenumber Page Number Print Print Print Print
partner Partner main Off Off Off Off
paymentmethod Pymt. Method payment Both Both
paypalstatus PayPal Status payment Screen
paypaltranid PayPal Tran. ID payment Screen
percentcomplete % Complete Off Off
porate PO Rate Off Off
povendor PO Vendor Off Off
project Project Print Print Print Print
promocode Promotion Code items Both Both
quantity Quantity Both Both Both Both
quantityavailable Available Off Off
quantitybackordered
Back Ordered Off Off
quantitycommitted Committed Off Off
quantityfulfilled Quantity This Shipment
Off Off
quantityonhand On Hand Off Off
quantityreceived Received Screen Screen
rate Rate Both Both Both Both
Code Name Field Name Tab Remittance Slip
Return Request - Credit
Return Request - Cash
Online Order - Invoice
Online Order - Cash Sale
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
51
revrecenddate Revenue Recognition End Date
main Off Off Off Off
revrecenddate Revenue Recognition End Date
Off Off Off Off
revrecschedule Revenue Recognition Schedule
main Off Off Off Off
revrecschedule Revenue Recognition Schedule
Off Off Off Off
revrecstartdate Revenue Recognition Start Date
main Off Off Off Off
revrecstartdate Revenue Recognition Start Date
Off Off Off Off
salesrep Sales Rep main Off Off Off Off
shipaddress Ship To address Off Off Both Both
shipdate Ship Date shipping Print Print
shipid Shipment # shipping
shipmethod Ship Via shipping Both Both
shippingcost Shipping Cost shipping Off Off
shipto Customer main
startdate Start Date main Off Off
startdate Start Date
subname Subcustomer/Job
subtotal Subtotal Both Both Both Both
supervisorapproval Supervisor Approval
main
tax1amt Tax Amt Both Both Both Both
taxcode Tax Code Screen Screen Screen Screen
taxitem Tax Item items Screen Screen Screen Screen
taxrate Tax Rate items Screen Screen Screen Screen
taxrate1 Tax Rate Both Both Both Both
taxtotal Tax Total Both Both Both Both
Code Name Field Name Tab Remittance Slip
Return Request - Credit
Return Request - Cash
Online Order - Invoice
Online Order - Cash Sale
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
52
Table 2
terminmonths Revenue Recognition Term in Months
terms Terms main Off
terms Terms
title Title main
tobeemailed To Be E-mailed output Off Off Off Off
tobefaxed To Be Faxed output Off Off Off Off
tobeprinted To Be Printed output Off Off Off Off
total Total Both Both Both Both
totalpackages Total Pkgs. main
totalweight Total Weight main
trackingnumbers Tracking # shipping Both Both
trandate Date main Both Both Both Both
trandocnkey Record
tranid Doc. No. main Print Both Both Both Both
ultimatedestination Ultimate Destination
main
unapplied Unapplied items
units Units
vatregnum Tax Id main Both Both Both Both
weight Weight items
weightedtotal Weighted Total main
winlossreason Win/Loss Reason main
Code Name Field Name Tab Remittance Slip
Return Request - Credit
Return Request - Cash
Online Order - Invoice
Online Order - Cash Sale
Code Name Field Name Tab OpportunityDrop Ship Purchase Order
Shipping Label
Return Form Statement
account Account main Screen
accountnumber Acct. No. Off
actionitem Action Item main Screen
aging1 Aging: Current Print
aging2 Aging: 1-30 Days Print
aging3 Aging: 31-60 Days Print
aging4 Aging: 61-90 Days Print
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
53
aging5 Aging: Over 90 Days
agingbal Aging: Amount Due
altsalesamt Alt.Sales Screen
amount Amount Screen Both
amountdue Amount Due Print
amountenclosed Amount Encl. Print
amountremaining Open Amount Off
availableoffline Always Available Offline
main Screen
balance Balance main Off
balance Balance Print
barcode Barcode Print Print
billaddress Bill To address Both Both Print
charge Charge Print
class Class Off Screen
class Class main Screen Screen
companyaddress Company Address Print Print Print
companyfednum Business Number Off Off Off
companylogo Company Logo Print Print
companyname Company Name Off Print Print Off
companyphone Company Phone Off Off Off
companyurl Company URL Off Off Off
createdfrom Created From main Screen
creditlimit Credit Limit Off
currencyname Currency items Screen Screen
customer Customer Screen
customername Customer Print
customform Custom Form main Screen Screen
datecol Date Print
department Department Off Screen
department Department main Screen Screen
description Description Screen Both Print
duedate Due Date main Both
Code Name Field Name Tab OpportunityDrop Ship Purchase Order
Shipping Label
Return Form Statement
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
54
duedate Due Date Off
employee Employee main Screen
enddate End Date Off
entity Entity main Screen Screen
entitystatus Entity Status main Screen
exchangerate Exchange Rate items Screen Screen
expectedclosedate Exp. Close Date main Screen
fob FOB shipping Off
forecasttype Forecast Type main Screen
formtitle Form Title Print Print Print
grossamt Gross Amt Both Both
isbillable Billable Screen
item Item Screen Both Print
job Job Off
leadsource Lead Source main Screen
location Location Off Off
location Location main Screen Screen
memo Memo main Screen Screen
memo Memo Off
message Message output Both
options Options Both
orderstatus Order Status main
otherrefnum Ref. No. main Both
otherrefnum PO/Check # Off
pagenumber Page Number Print Print Print
partner Partner main Screen
payment Payment Print
probability Probability main Screen
projaltsalesamt Alt.Sales Amount main Screen
project Project Off
projectedtotal Projected Total main Screen
quantity Quantity Screen Both Print
quantityavailable Available Off Off
quantityonhand On Hand Off Off
Code Name Field Name Tab OpportunityDrop Ship Purchase Order
Shipping Label
Return Form Statement
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
55
quantityreceived Received Screen
rate Rate Screen Both
reason Reason For Returning
returnaddress Ship Returns To Print
rmanum Ret. Auth. # Print
salesrep Sales Rep main Screen Off
serialnumbers Serial Numbers Screen Both
shipaddress Ship To address Both Both Print
shipdate Ship Date shipping Both
shipmethod Ship Via shipping Both
shipto Customer main Screen
startdate Start Date Off
subname Subcustomer/Job Off
subtotal Subtotal Both
supervisorapproval Supervisor Approval
main Screen
tax1amt Tax Amt Both Both
taxcode Tax Code Screen Screen
taxrate1 Tax Rate Both Both
terminmonths Revenue Recognition Term in Months
Off
terms Terms main Off Off
terms Terms Off
title Title main Screen
tobeemailed To Be E-mailed output Screen
tobefaxed To Be Faxed output Screen
tobeprinted To Be Printed output Screen
total Total Both
trackingnumbers Tracking # shipping Both
trandate Date main Screen Both Print
tranid Doc. No. main Screen Both Print
units Units Screen Both
vatregnum Tax Id main Both Both
Code Name Field Name Tab OpportunityDrop Ship Purchase Order
Shipping Label
Return Form Statement
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
56
Table 3
weightedtotal Weighted Total main Screen
winlossreason Win/Loss Reason main Screen
Code Name Field Name Tab OpportunityDrop Ship Purchase Order
Shipping Label
Return Form Statement
Code Name Field Name Tab Packing Slip
Picking Ticket
Return Authorization - Cash
Return Authorization - Credit
Sales Order - Progress Billing
accountnumber Acct. No. Off Off Off Off Off
altsalesamt Alt.Sales Screen Screen Screen
amount Amount Both Both Both
balance Balance main Off
balance Balance
barcode Barcode Print Print Print Print Print
billaddress Bill To address Off Both Both Both
billingschedule Bill. Sched. main Screen
billingschedule Billing Schedule Off
ccapproved Credit Card Approved
payment Screen
ccnumber Credit Card # payment Both Both
class Class Off Off Off Off
class Class main Screen Screen Screen
companyaddress Company Address Print Print Print Print Print
companyfednum Business Number Off Off Off Off Off
companylogo Company Logo Print Print Print Print Print
companyname Company Name Off Off Off Off Off
companyphone Company Phone Off Off Off Off Off
companyurl Company URL Off Off Off Off Off
createdfrom Created From main Screen Screen Screen
createpo Create PO Screen
creditcardprocessor Credit Card Processor
payment Screen
currencyname Currency items Screen Screen Screen
customform Custom Form main Screen Screen Screen
department Department Off Off Off Off
department Department main Screen Screen Screen
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
57
description Description Print Print Both Both Both
discountitem Discount items Both Both Both
enddate End Date main Off Screen
entity Entity main Screen Screen Screen
exchangerate Exchange Rate items Screen Screen Screen
excludecommission Exclude Commissions
main Screen Screen Screen
fob FOB shipping Off Off
formtitle Form Title Print Print Print Print Print
grossamt Gross Amt Both Both Both
istaxable Tax Both Both Both
istaxable Taxable items Screen Screen Screen
item Item Print Print Both Both Both
job Job Off Off Off Off
location Location Off Off Off Off Off
location Location main Screen Screen Screen
memo Memo main Off Off Screen Screen Screen
message Message output Print Both Both Both
opportunity Opportunity main Screen
options Options Print Print Both Both Both
orderstatus Order Status main Screen Screen Screen
otherrefnum Ref. No. main Off Off Both Both Both
pagenumber Page Number Print Print Print Print Print
partner Partner main Off Screen Screen Screen
paymentmethod Pymt. Method payment Off Both
percentcomplete % Complete Screen
porate PO Rate Off
povendor PO Vendor Off
project Project Off Print Print Print
promocode Promotion Code items Both Both Both
quantity Quantity Print Print Both Both Off
quantitybackordered
Back Ordered Off
quantitycommitted Committed Print
Code Name Field Name Tab Packing Slip
Picking Ticket
Return Authorization - Cash
Return Authorization - Credit
Sales Order - Progress Billing
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
58
quantityfulfilled Quantity This Shipment
quantityonhand On Hand Off
quantityordered Qty. Ordered Print
quantityreceived Received Screen Screen
quantityremaining Remaining Print Off
rate Rate Both Both Off
revrecenddate Revenue Recognition End Date
main Off Off Off
revrecenddate Revenue Recognition End Date
Screen Screen Screen
revrecschedule Revenue Recognition Schedule
main Off Off Off
revrecschedule Revenue Recognition Schedule
Screen Screen Screen
revrecstartdate Revenue Recognition Start Date
main Off Off Off
revrecstartdate Revenue Recognition Start Date
Screen Screen Screen
salesrep Sales Rep main Off Screen Screen Screen
serialnumbers Serial Numbers Print Print Both Both Off
shipaddress Ship To address Print Print Off Off Off
shipdate Ship Date shipping Print Off Off
shipid Shipment # shipping Off
shipmethod Ship Via shipping Print Off Off
shippingcost Shipping Cost shipping Off
startdate Start Date main Off Screen
subtotal Subtotal Both Both Both
tax1amt Tax Amt Both Both Both
taxcode Tax Code Screen Screen Screen
taxitem Tax Item items Screen Screen Screen
taxrate Tax Rate items Screen Screen Screen
Code Name Field Name Tab Packing Slip
Picking Ticket
Return Authorization - Cash
Return Authorization - Credit
Sales Order - Progress Billing
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
59
Table 4
taxrate1 Tax Rate Both Both Both
taxtotal Tax Total Both Both Both
terminmonths Revenue Recognition Term in Months
Off Off Off
terms Terms main Both
tobeemailed To Be E-mailed output Screen Screen Screen
tobefaxed To Be Faxed output Screen Screen Screen
tobeprinted To Be Printed output Screen Screen Screen
total Total Both Both Both
trackingnumbers Tracking # shipping Print Off Off
trandate Date main Print Print Both Both Both
tranid Doc. No. main Print Print Both Both Both
units Units Print Print Both Both Off
vatregnum Tax Id main Both Both Both
Code Name Field Name Tab Packing Slip
Picking Ticket
Return Authorization - Cash
Return Authorization - Credit
Sales Order - Progress Billing
Code Name Field Name Tab Progress Invoice
Sales Order - Cash Sale
Sales Order - Invoice
Canada Finance Charge
Service Invoice
account Account main Screen Screen Screen
accountnumber Acct. No. Off Off Off Off Off
aging1 Aging: Current Off Off Off
aging2 Aging: 1-30 Days Off Off Off
aging3 Aging: 31-60 Days Off Off Off
aging4 Aging: 61-90 Days Off Off Off
aging5 Aging: Over 90 Days
Off Off Off
agingbal Aging: Amount Due
Off Off Off
altsalesamt Alt.Sales Screen Screen
amount Amount Both Both Both Both Both
amountordered Order Amt. Both Off
amountpaid Amount Paid main Off Off Off
amountremaining Amount Remaining
main Off Off Off
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
60
balance Balance main Off Off Off Off
barcode Barcode Print Print Print Print Print
billaddress Bill To address Both Both Both Both Both
billeddate Date Billed Off Off
billingschedule Bill. Sched. main Screen Screen
billingschedule Billing Schedule Off Off
ccapproved Credit Card Approved
payment Screen
ccnumber Credit Card # payment Both
class Class Off Off Off Off Off
class Class main Screen Screen Screen Screen Screen
companyaddress Company Address Print Print Print Print Print
companyfednum Business Number Off Off Off Off Off
companylogo Company Logo Print Print Print Print Print
companyname Company Name Off Off Off Off Off
companyphone Company Phone Off Off Off Off Off
companyurl Company URL Off Off Off Off Off
createdfrom Created From main Screen Screen Screen Screen Screen
createpo Create PO Screen Screen
creditcardprocessor Credit Card Processor
payment Screen
currencyname Currency items Screen Screen Screen Screen Screen
currentpercent Current % Both Off
customform Custom Form main Screen Screen Screen Screen Screen
department Department Off Off Off Off Off
department Department main Screen Screen Screen Screen Screen
description Description Both Both Both Both Both
discountamount Disc. Amt. main Off Off
discountdate Disc. Date main Off Off
discountitem Discount items Both Both Both Both Both
duedate Due Date main Both Both Both
employee Employee (Initials) Off Off
employeefullname Employee (Full Name)
Off Off
enddate End Date main Screen Screen Screen Both
Code Name Field Name Tab Progress Invoice
Sales Order - Cash Sale
Sales Order - Invoice
Canada Finance Charge
Service Invoice
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
61
entity Entity main Screen Screen Screen Screen Screen
event Event Off Off
exchangerate Exchange Rate items Screen Screen Screen Screen Screen
excludecommission
Exclude Commissions
main Screen Screen
fob FOB shipping Off Off Off Off Off
formtitle Form Title Print Print Print Print Print
grossamt Gross Amt Both Both Both Both Both
istaxable Tax Both Both Both Both Both
istaxable Taxable items Screen Screen Screen Off Screen
item Item Both Both Both Both Both
job Job Off Off Off Off
location Location Off Off Off Off Off
location Location main Screen Screen Screen Screen Screen
memo Memo main Screen Screen Screen Screen Screen
message Message output Both Both Both Both Both
opportunity Opportunity main Screen Screen Screen Screen
options Options Both Both Both Off Both
orderstatus Order Status main Screen Screen
otherrefnum Ref. No. main Both Both Both Off Both
pagenumber Page Number Print Print Print Print Print
partner Partner main Screen Screen Screen Off Screen
paymentmethod Pymt. Method payment Both
paypalstatus PayPal Status payment Screen
paypaltranid PayPal Tran. ID payment Screen
percentcomplete % Complete Both Off Off Off
porate PO Rate Off Off
postingperiod Posting Period main Screen Screen Screen
povendor PO Vendor Off Off
project Project Print Print Print Print Print
promocode Promotion Code items Both Both Both Both Both
quantity Quantity Off Both Both Off Both
quantityavailable Available Off Off Off
quantitybackordered
Back Ordered Screen Screen
Code Name Field Name Tab Progress Invoice
Sales Order - Cash Sale
Sales Order - Invoice
Canada Finance Charge
Service Invoice
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
62
quantitycommitted Committed Screen Screen
quantityfulfilled Quantity This Shipment
Screen Screen Off
quantityonhand On Hand Off Off Off
quantityordered Qty. Ordered Off Off
quantityremaining Remaining Screen
rate Rate Off Both Both Off Both
revrecenddate Revenue Recognition End Date
main Off Off Off Off Off
revrecenddate Revenue Recognition End Date
Screen Screen Screen Screen Screen
revrecschedule Revenue Recognition Schedule
main Off Off Off Off Off
revrecschedule Revenue Recognition Schedule
Screen Screen Screen Screen Screen
revrecstartdate Revenue Recognition Start Date
main Off Off Off Off Off
revrecstartdate Revenue Recognition Start Date
Screen Screen Screen Screen Screen
salesrep Sales Rep main Screen Screen Screen Off Screen
serialnumbers Serial Numbers Off Both Both Off Both
shipaddress Ship To address Off Both Both Off Off
shipdate Ship Date shipping Off Both Both Off Off
shipmethod Ship Via shipping Off Both Both Off
shippingcost Shipping Cost shipping Off Off Off Off
startdate Start Date main Screen Screen Screen Both
subtotal Subtotal Both Both Both Both Both
tax1amt Tax Amt Both Both Both Both Both
taxcode Tax Code Screen Screen Screen Screen Screen
taxitem Tax Item items Screen Screen Screen Off Screen
taxrate Tax Rate items Screen Screen Screen Off Screen
taxrate1 Tax Rate Both Both Both Both Both
taxtotal Tax Total Both Both Both Both Both
Code Name Field Name Tab Progress Invoice
Sales Order - Cash Sale
Sales Order - Invoice
Canada Finance Charge
Service Invoice
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
63
Table 5
terminmonths Revenue Recognition Term in Months
Off Off
terms Terms main Both Both Both Both
tobeemailed To Be E-mailed output Screen Screen Screen Screen Screen
tobefaxed To Be Faxed output Screen Screen Screen Screen Screen
tobeprinted To Be Printed output Screen Screen Screen Screen Screen
total Total Both Both Both Both Both
trackingnumbers Tracking # shipping Off Both Both Off
trandate Date main Both Both Both Both Both
tranid Doc. No. main Both Both Both Both Both
units Units Off Both Both Off Both
vatregnum Tax Id main Both Both Both Both Both
Code Name Field Name Tab Progress Invoice
Sales Order - Cash Sale
Sales Order - Invoice
Canada Finance Charge
Service Invoice
Code Name Field Name Tab Product Invoice
Professional Invoice Credit Memo Cash Sale
account Account main Screen Screen Screen Screen
accountnumber Acct. No. Off Off Off Off
aging1 Aging: Current Off Off
aging2 Aging: 1-30 Days Off Off
aging3 Aging: 31-60 Days Off Off
aging4 Aging: 61-90 Days Off Off
aging5 Aging: Over 90 Days
Off Off
agingbal Aging: Amount Due
Off Off
amount Amount Both Both Both Both
amountordered Order Amt. Off Off Off
amountpaid Amount Paid main Off Off Off
amountremaining Amount Remaining
main Off Off Off
applied Applied items Screen
balance Balance main Off Off Off
barcode Barcode Print Print Print Print
billaddress Bill To address Both Both Both Both
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
64
billeddate Date Billed Off Off
ccapproved Credit Card Approved
payment Screen
ccnumber Credit Card # payment Both
class Class Off Off Off Off
class Class main Screen Screen Screen Screen
companyaddress Company Address Print Print Print Print
companyfednum Business Number Off Off Off Off
companylogo Company Logo Print Print Print Print
companyname Company Name Off Off Off Off
companyphone Company Phone Off Off Off Off
companyurl Company URL Off Off Off Off
createdfrom Created From main Screen Screen Screen Screen
creditcardprocessor Credit Card Processor
payment Screen
currencyname Currency items Screen Screen Screen Screen
currentpercent Current % Off Off Off
customform Custom Form main Screen Screen Screen Screen
department Department Off Off Off Off
department Department main Screen Screen Screen Screen
description Description Both Both Both Both
discountamount Disc. Amt. main Off Off
discountdate Disc. Date main Off Off
discountitem Discount items Both Both Both Both
duedate Due Date main Both Both
employee Employee (Initials) Off Off
employeefullname Employee (Full Name)
Off Off
enddate End Date main Screen Both Both
entity Entity main Screen Screen Screen Screen
entitystatus Entity Status main
event Event Off Off
exchangerate Exchange Rate items Screen Screen Screen Screen
fob FOB shipping Both Off Off
formtitle Form Title Print Print Print Print
grossamt Gross Amt Both Both Both Both
Code Name Field Name Tab Product Invoice
Professional Invoice Credit Memo Cash Sale
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
65
istaxable Tax Both Both Both Both
istaxable Taxable items Screen Screen Screen Screen
item Item Both Both Both Both
job Job Off Off Off Off
location Location Off Off Off Off
location Location main Screen Screen Screen Screen
memo Memo main Screen Screen Screen Screen
message Message output Both Both Both Both
opportunity Opportunity main Screen Screen Screen
options Options Both Both Both Both
otherrefnum Ref. No. main Both Off Both Both
pagenumber Page Number Print Print Print Print
partner Partner main Both Screen Screen Screen
paymentmethod Pymt. Method payment Both
paypalstatus PayPal Status payment Screen
paypaltranid PayPal Tran. ID payment Screen
percentcomplete % Complete Off Off Off
postingperiod Posting Period main Screen Screen Screen Screen
project Project Print Print Print Print
promocode Promotion Code items Both Both Both Both
quantity Quantity Both Off Both Both
quantityavailable Available Off Off Off
quantityfulfilled Quantity This Shipment
Off Off Off
quantityonhand On Hand Off Off Off
quantityordered Qty. Ordered Off Off Off
quantityremaining Remaining Screen Off Screen
rate Rate Both Off Both Both
revrecenddate Revenue Recognition End Date
main Off Off Off Off
revrecenddate Revenue Recognition End Date
Screen Screen Screen Screen
revrecschedule Revenue Recognition Schedule
main Off Off Off Off
Code Name Field Name Tab Product Invoice
Professional Invoice Credit Memo Cash Sale
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
66
revrecschedule Revenue Recognition Schedule
Screen Screen Screen Screen
revrecstartdate Revenue Recognition Start Date
main Off Off Off Off
revrecstartdate Revenue Recognition Start Date
Screen Screen Screen Screen
salesrep Sales Rep main Both Screen Screen Screen
serialnumbers Serial Numbers Both Off Both Both
shipaddress Ship To address Both Off Off
shipdate Ship Date shipping Both Off Off
shipmethod Ship Via shipping Both Off Off Off
shippingcost Shipping Cost shipping Off Off Off Off
startdate Start Date main Screen Both Both
subtotal Subtotal Both Both Both Both
tax1amt Tax Amt Both Both Both Both
taxcode Tax Code Screen Screen Screen Screen
taxitem Tax Item items Screen Screen Screen Screen
taxrate Tax Rate items Screen Screen Screen Screen
taxrate1 Tax Rate Both Both Both Both
taxtotal Tax Total Both Both Both Both
terms Terms main Both Both
tobeemailed To Be E-mailed output Screen Screen Screen Screen
tobefaxed To Be Faxed output Screen Screen Screen Screen
tobeprinted To Be Printed output Screen Screen Screen Screen
total Total Both Both Both Both
trackingnumbers Tracking # shipping Both Off Off
trandate Date main Both Both Both Both
tranid Doc. No. main Both Both Both Both
unapplied Unapplied items Screen
units Units Both Off Both Both
vatregnum Tax Id main Both Both Both Both
Code Name Field Name Tab Product Invoice
Professional Invoice Credit Memo Cash Sale
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
67
Table 6
Code Name Field Name Tab Cash Refund Estimate Purchase Order
Finance Charge
account Account main Screen Screen Screen
accountnumber Acct. No. Off Off Off
aging1 Aging: Current Off
aging2 Aging: 1-30 Days Off
aging3 Aging: 31-60 Days Off
aging4 Aging: 61-90 Days Off
aging5 Aging: Over 90 Days
Off
agingbal Aging: Amount Due
Off
altsalesamt Alt.Sales Screen
amount Amount Both Both Both Both
amountpaid Amount Paid main Off
amountremaining Amount Remaining
main Off
balance Balance main Off Off
barcode Barcode Print Print Print Print
billaddress Bill To address Both Both Both Both
billingschedule Bill. Sched. main Screen
billingschedule Billing Schedule Off
ccapproved Credit Card Approved
payment Screen
ccnumber Credit Card # payment Both
class Class Off Off Screen Off
class Class main Screen Screen Screen Screen
companyaddress Company Address Print Print Print Print
companyfednum Business Number Off Off Off Off
companylogo Company Logo Print Print Print Print
companyname Company Name Off Off Off Off
companyphone Company Phone Off Off Off Off
companyurl Company URL Off Off Off Off
createdfrom Created From main Screen Screen Screen
creditcardprocessor Credit Card Processor
payment Screen
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
68
currencyname Currency items Screen Screen Screen Screen
customer Customer Screen
customform Custom Form main Screen Screen Screen Screen
department Department Off Off Screen Off
department Department main Screen Screen Screen Screen
description Description Both Both Both Both
discountitem Discount items Both Both Both
duedate Due Date main Both Both Both
employee Employee main Screen
enddate End Date main Off
entity Entity main Screen Screen Screen Screen
entitystatus Entity Status main Screen
exchangerate Exchange Rate items Screen Screen Screen Screen
expectedclosedate Exp. Close Date main Both
fob FOB shipping Off Off Off
forecasttype Forecast Type main Screen
formtitle Form Title Print Print Print Print
grossamt Gross Amt Both Both Both Both
includeinforecast Include In Forecast
main Screen
isbillable Billable Screen
istaxable Tax Both Both Off
istaxable Taxable items Screen Screen Off
item Item Both Both Both Both
job Job Off Off
location Location Off Off Off Off
location Location main Screen Screen Screen Screen
memo Memo main Screen Screen Screen Screen
message Message output Both Both Both Both
opportunity Opportunity main Screen
options Options Both Both Both Off
otherrefnum Ref. No. main Both Off Both Off
pagenumber Page Number Print Print Print Print
partner Partner main Screen Screen Off
paymentmethod Pymt. Method payment Both
Code Name Field Name Tab Cash Refund Estimate Purchase Order
Finance Charge
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
69
postingperiod Posting Period main Screen Screen
probability Probability main Screen
project Project Print Print Print
promocode Promotion Code items Both Both Both
quantity Quantity Both Both Both Off
quantityavailable Available Off Off
quantityonhand On Hand Off Off
quantityreceived Received Screen
rate Rate Both Both Both Off
revrecenddate Revenue Recognition End Date
main Off Off
revrecenddate Revenue Recognition End Date
Screen Screen
revrecschedule Revenue Recognition Schedule
main Off Off
revrecschedule Revenue Recognition Schedule
Screen Screen
revrecstartdate Revenue Recognition Start Date
main Off Off
revrecstartdate Revenue Recognition Start Date
Screen Screen
salesrep Sales Rep main Screen Screen Off
serialnumbers Serial Numbers Both Both Both Off
shipaddress Ship To address Off Off Off
shipdate Ship Date shipping Off Off Off
shipmethod Ship Via shipping Off Off Off
shippingcost Shipping Cost shipping Off Off
shipto Customer main Off
startdate Start Date main Off
subtotal Subtotal Both Both Both Both
supervisorapproval Supervisor Approval
main Screen
tax1amt Tax Amt Both Both Both Both
Code Name Field Name Tab Cash Refund Estimate Purchase Order
Finance Charge
Client SuiteScript Developer’s Guide
Code Names Code Names by Field Type
70
taxcode Tax Code Screen Screen Screen Screen
taxitem Tax Item items Screen Screen Off
taxrate Tax Rate items Screen Screen Off
taxrate1 Tax Rate Both Both Both Both
taxtotal Tax Total Both Both Both
terminmonths Revenue Recognition Term in Months
Off
terms Terms main Off Off Both
tobeemailed To Be E-mailed output Screen Screen Screen Screen
tobefaxed To Be Faxed output Screen Screen Screen Screen
tobeprinted To Be Printed output Screen Screen Screen Screen
total Total Both Both Both Both
trackingnumbers Tracking # shipping Off Off
trandate Date main Both Both Both Both
tranid Doc. No. main Both Both Both Both
units Units Both Both Both Off
vatregnum Tax Id main Both Both Both Both
Code Name Field Name Tab Cash Refund Estimate Purchase Order
Finance Charge
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code
Following is the complete code used for the tutorial in Chapter 3 "Client SuiteScript Tutorial". Copy this information exactly as it appears here. Comments are included in the code to help illustrate the purpose of each portion of the code.
//=====================================================function samplePageInit(){
// Customers that make purchases in the store, as opposed to from a Web site, // automatically receives a 5% in-store transaction discount. This discount is // NOT in addition to other discounts they may have available to them.// // NOTE: you could also have used nlapiSetFieldText('discountitem', 'In-store // Discount');// The 92 is the ID of the item in your NetSuite account. You can determine the // ID of an item by navigating to the item, and inspecting the id= parameter of // the URL.
nlapiSetFieldValue('discountitem', 92);}
//=====================================================
function sampleSaveRecord(){
return confirm("Are you sure you want to save this record?");}
//=====================================================
function sampleValidateField(type, name){
// This script does not allow discounts equal to or greater than $50 or greater // than 30%, without manager approval.// If the transaction discount rate is positive, which adds to the order total,// prompt to reset the transaction discount to the better of the In-store or // Cust. Discount.//// Also, if the rate is a percent and is not as high as the Cust. Discount or// In-store Discount, check to see if they would like to reset the discount// to the higher rate.
// The three variable initialization functions that are called from this // function (calcIsPercent, calcTransactionDiscountRate and // calcCustomerDiscountRate) are defined at the end of this script file.
if (name == 'discountrate'){
// intialize variables
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code 72
// Customers that purchase in the store, as opposed to from a Web site, // automatically receive a 5% in-store transaction discount.var instore_discount = -5;
// Start by assuming the customer discount is better than the in-store // discount.var useCustomerDiscount = true;
// Is the transaction discount field a percent?var isPercent = calcIsPercent();
// If a transaction discount is present, set tran_discount_rate,// otherwise initialize to zero.var tran_discount_rate = calcTransactionDiscountRate();
// If a customer discount is present, set cust_discount,// otherwise initialize to zero.var cust_discount = calcCustomerDiscountRate();
// If the In-store discount is higher than the customer discount, use it // instead.if ( instore_discount <= cust_discount )
useCustomerDiscount = false;
// Check to see that the discount is not a percent.if (!isPercent) {
// If the discount is not a percent...// Is the transaction discount rate > 0 (which adds to the order total)? // If so, prompt to reset Transaction Discount to the higher of In-house or // Cust. Discountif (tran_discount_rate > 0){
if ( confirm("The Transaction Discount Rate is positive, which adds to the order total.\n\nReset Transaction Discount to the better of Cust. Discount or In-store Discount?\n\n(OK = Yes, Cancel = No)") ){
// Use the higher of the In-store or the Cust. Discount rate.if( useCustomerDiscount ){
// alert("custbody_cust_discount: '" +nlapiGetFieldText('custbody_cust_discount') + "'");nlapiSetFieldText('discountitem', nlapiGetFieldText('custbody_cust_discount'));
}else{
nlapiSetFieldText('discountitem', "In-store Discount");}
}}// If the discount is not percent, is the discount equal to or more than // $50?else if (parseInt(nlapiGetFieldValue('discountrate')) <= -50){
if (!confirm("Please confirm that you have a manager's approval for this discount amount.\n\n(OK = Yes, Cancel = No)")){
// Use the higher of the In-store or the Cust. Discount rateif( useCustomerDiscount ){
alert("Discount level not approved, resetting to Customer
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code 73
Discount.");
// alert("custbody_cust_discount: '" +nlapiGetFieldText('custbody_cust_discount') + "'");nlapiSetFieldText('discountitem',nlapiGetFieldText('custbody_cust_discount'));
}else{
alert("Discount level not approved, resetting to In-store Discount.");
nlapiSetFieldText('discountitem', "In-store Discount");}
}}
}
// If the discount is a percent...// Is that percent more than 30% off?else{
if ( parseFloat(nlapiGetFieldValue('discountrate')) < -30 ){
// If so, prompt...if (!confirm("Please confirm that you have a manager's approval for this discount percent.\n\n(OK = Yes, Cancel = No)")){
// Reset to the higher of In-store discount or Cust. Discount.if( useCustomerDiscount ){
alert("Discount level not approved, resetting to Customer Discount.");
nlapiSetFieldText('discountitem',nlapiGetFieldText('custbody_cust_discount'));
}else{
alert("Discount level not approved, resetting to In-store Discount.");
nlapiSetFieldText('discountitem', "In-store Discount");}
}}
// If the Transaction Discount Rate is a percent and is lower than Cust. // Discount or In-Store Discount, then prompt to reset Transaction Discount // to the higher of the two.if (tran_discount_rate > cust_discount || tran_discount_rate > instore_discount){
if ( confirm("The Transaction Discount Rate is not as good as the Cust. Discount or the In-store Discount.\n\nReset Transaction Discount to the better of the two?\n\n(OK = Yes, Cancel = No)") ){
// Use the higher of the In-store or Cust. Discount rate.if( useCustomerDiscount ){
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code 74
// alert("custbody_cust_discount: '" +nlapiGetFieldText('custbody_cust_discount') + "'");nlapiSetFieldText('discountitem',nlapiGetFieldText('custbody_cust_discount'));
}else{
nlapiSetFieldText('discountitem', "In-store Discount");}
}}
}}
// If any single line-item quantity exceeds 20, ask if this is correct.else if ( (type == 'item') && (name == 'quantity') ){
var count = parseFloat(nlapiGetCurrentLineItemValue('item', 'quantity'));
if(count > 20){
return confirm("Do you really want to add " + count + " of this item?\n\n(OK = Yes, Cancel = No)");
}}
// Always return true at this level to validate all the fields that you// are not specifically validating...return true;
}
//=====================================================
function sampleFieldChanged(type, name){
// A custom checkbox field for customers records whether the customer has "had // order problems."// A locked transaction body field (checkbox) sources the value from the // customer record onto the transaction.// On field change of customer (entity), check the sourced locked field. If it // is "T", then pop an alert saying// "This customer has had order problems previously. Be sure to verify all // items with the customer before// submitting the order."
if (name == 'custbody_had_order_problems'){
// if customer is not null and this customer has had order problems,// remind the employee to double check the order...if ( (nlapiGetFieldValue('custbody_had_order_problems') == 'T') && (nlapiGetFieldText('entity')) ){
alert("This customer has had order problems previously. Be sure to verify all items with the customer before submitting the order.");return true;
}
}return true;
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code 75
}
//=====================================================
function sampleValidateLine(type){
// Prevents a service line item to be added without specifying the service rep // employee.
// alert("service item flag: " + nlapiGetCurrentLineItemValue('item', // 'custcol_service_item'));// alert("service rep: " + nlapiGetCurrentLineItemText('item', // 'custcol_service_rep'));
// if ( (nlapiGetCurrentLineItemValue('item', 'custcol_service_item') == 'T') // && (String(nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) == // "") )
if ( (nlapiGetCurrentLineItemValue('item', 'custcol_service_item') == 'T') &&(!nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) )//(nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) == "" )
{alert("You must choose a Service Rep for this service item.");return false;
}
return true;}
//=====================================================
function sampleRecalc(type){
// For each service line item that is added, its total is added to the service// bookings field.//// The custcol_service_item field sources its value from the Service Item// custom field checkbox on the item.
// initialize totalvar total = 0;
// Run through each line item looking for service items.for ( i = 1; i <= nlapiGetLineItemCount('item'); i++){
// Set item_amount for the current item.var item_amount = parseFloat(nlapiGetLineItemValue('item', 'amount', i));
// If the item is a service item, add its value to the total.if (nlapiGetLineItemValue('item', 'custcol_service_item', i) == 'T'){
total += item_amount;}
}
// Set the service bookings custom field to the total of all service items.nlapiSetFieldValue('custbody_service_bookings', nlapiFormatCurrency(total));
Client SuiteScript Developer’s Guide
Appendix: Tutorial Code 76
}
//=====================================================
//// The following scripts are the three variable init functions called from the // sampleValidateField function.//
function calcIsPercent(){
// If you cannot find a percent sign in the discount field, set isPercent to // false.if( nlapiGetFieldValue('discountrate').indexOf('%') == -1 )
return false;else
return true;
}
function calcTransactionDiscountRate(){
// If a transaction discount is present, set tran_discount_rate,// otherwise initialize to zero.
if( !isNaN(parseFloat(nlapiGetFieldValue('discountrate'))) )return parseFloat(nlapiGetFieldValue('discountrate'));
elsereturn 0;
}
function calcCustomerDiscountRate(){
if( !isNaN(parseFloat(nlapiGetFieldText('custbody_cust_discount'))) )// Multiply the rate by -1 because all discounts must be negative or they// add to order total.return ((parseFloat(nlapiGetFieldText('custbody_cust_discount'))) * -1);
elsereturn 0;
}//=====================================================
Client SuiteScript Developer’s Guide