Client SuiteScript Developer s Guide
Copyright NetSuite, Inc. 2005 All rights reserved. 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................................................... 1 Roles & Permissions............................................. 1 Chapter 2 Using Client SuiteScript General Guidelines............................................... 3 Getting Started.................................................. 4 Enabling the Client SuiteScript Feature and Preferences......................... 4 Field Names (IDs)............................................................... 5 Attaching Client SuiteScripts to Forms.......................................... 5 Functions....................................................... 6 PageInit....................................................................... 7 SaveRecord.................................................................... 8 PostSourcing................................................................... 9 ValidateField................................................................... 9 FieldChanged................................................................. 10 Client SuiteScript API........................................... 10 Using the Fire Field Changed Parameter....................................... 13 Working with Line Items....................................................... 14 Chapter 3 Client SuiteScript Tutorial Customizing the Page Load...................................... 16 Setup......................................................................... 16 Create the Code............................................................... 16 Test the Code.................................................................. 17 Validating Field Values.......................................... 18 Setup......................................................................... 18 Create the Code............................................................... 19 Test the Code.................................................................. 20 More Validation............................................................... 21 Triggering Events when a Field is Changed......................... 21 Setup......................................................................... 21 Create the Code............................................................... 22 Test the Code.................................................................. 22 Validating a Line Item........................................... 23 Setup......................................................................... 23 Create the Code............................................................... 23 Test the Code.................................................................. 24
Recalculating Field Totals........................................ 24 Setup......................................................................... 24 Create the Code............................................................... 25 Test the Code.................................................................. 25 Prompting before Save.......................................... 26 Create the Code............................................................... 26 Test the Code.................................................................. 26 Chapter 4 Code Names Code Names by Record Type..................................... 28 Case Record................................................................... 28 Contact Record................................................................ 29 Customer Record.............................................................. 30 Employee Record.............................................................. 31 Event Record.................................................................. 34 Partner Record................................................................ 34 Task Record................................................................... 35 Vendor Record................................................................ 35 Opportunity Record........................................................... 36 Code Names by Field Type....................................... 38 Entity Fields................................................................... 38 CRM Fields.................................................................... 42 Item Fields.................................................................... 44 Transaction Fields............................................................. 48 Appendix: Tutorial Code
Chapter 1 Welcome In This Guide 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. This 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 & Permissions NetSuite 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.
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 Administrator Full Access Marketing Manager Marketing Administrator Sales Manager Sales Administrator Support Administrator Access Level FULL FULL FULL FULL FULL FULL FULL
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 Guidelines Following 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.
Using Client SuiteScript Getting Started 4 Getting Started 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. Before 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.
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.
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. Functions NetSuite 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: String field 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.
Using Client SuiteScript Functions 7 Function Parameters Returns Description 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. 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 Field function pageinit() // is fielda is either NULL or equal to "valuea" if ((nlapigetfieldvalue('fielda').length == 0) (nlapigetfieldtext('fielda') == "valuea")) // then set fielda to valueb nlapisetfieldtext('fielda', nlapigetfieldtext('valueb')); Disable a Field function pageinit() // On init, disable two optional Other fields: fielda and fieldb. nlapidisablefield('custrecord_other_fielda', true); nlapidisablefield('custrecord_other_fieldb', true); Display User Profile Information function pageinit() // On page init display the currently logged in User's profile information. // Set variables var 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
Using Client SuiteScript Functions 8 // Display information alert("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 Information function 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 Location function saverecord(type,name) window.open('https://system.netsuite.com/[url string]');void(0) return true;
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 Lengths function ValidateField(type, name) // if fielda is not greater than 5 characters, fail validation if (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 fields return true;
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 Information function 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 API This 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
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 nlapisetcurrentlineitemvalue nlapigetlineitemvalue nlapisetlineitemvalue line item type: String; field name: String line item type: String; field name: String; value: String firefieldchanged: Boolean line item type: String; field name: String; line index: Integer line item type: String; field name: String; line index: Integer; value: String Retrieves the value of the given line-item field before it has been added to the form. Typically used in validate line functions. 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 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. 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.
Using Client SuiteScript Client SuiteScript API 12 Function Parameters Description nlapigetcurrentlineitemtext nlapigetlineitemtext nlapisetfieldtext nlapisetcurrentlineitemtext nlapidisablefield nlapidisablelineitemfield line item type: String; field name: String firefieldchanged: Boolean line item type: String; field name: String; line index: Integer field name: String; text value: String firefieldchanged: Boolean line item type: String; field name: String; text value: String field name: String; value: Boolean line item type: String; field name: String; value: 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 Gets the text value of the given selection field on the line item at the given index. 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 Sets the value of the given line-item selection field to the value with the given text. Sets the given field to disabled or enabled based on the value (true or false). 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: String line 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.
Using Client SuiteScript Client SuiteScript API 13 Function Parameters Description nlapisaverecord type: record type Saves the current record. id: internalid nlapicreaterecord type: record type Creates a new record instance. nlapisearchrecord nlapideleterecord nlapisendemail 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. type: record type searchid: saved search ID type: record type id: internalid 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 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. Allows you to search for other records in the system. Permanently deletes a record from the database. Generates and sends an email.
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');
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');
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 Load In 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. Element Parameters Purpose Discount Item Item Name/Number: In-store Discount Income Account: 4000 Sales Rate: 5% Apply Before Sales Tax: No 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); Defines the discount item that you will refer to in your custom code. To create, go to Lists > Accounting > Items > New > Discount.
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 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 Values Of 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 Tutorial Validating Field Values 19 Element Parameters Purpose 5 Discount Items Item Name/Number: 10%* Income Account: 4000 Sales Rate: 10%* Apply Before Sales Tax: No 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 Entity Field Transaction Body Field Customer Records And four additional discount items with the Item Name/Number and Rate fields to 15%, 20%, 25% and 30% respectively Name: Customer Discounts Values: 10%, 15%, 20%, 25%, 30% Description: Customer Discount ID: _customer_discount Type: List/Record List/Record: Customer Discounts Applies To: Customer:Job Subtab: General Description: Cust. Discount ID: _cust_discount Type: List/Record List/Record: Customer Discounts Applies To: Sale Subtab: Main Display Type: Disabled Source LIst: Entity Source From: Customer Discount Set a discount to various customers. Defines the selection list of discount items. To create, go to Setup > Customization > Lists > New. Sources the list just created. To create, go to Setup > Customization > Entity Fields > New. To create, go to Setup > Customization > Transaction Body Fields > New. 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.
Client SuiteScript Tutorial Validating Field Values 20 function calccustomerdiscountrate() if(!isnan(parsefloat(nlapigetfieldtext('custbody_cust_discount'))) ) return ((parsefloat(nlapigetfieldtext('custbody_cust_discount'))) * -1); else return 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 variables var 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 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 Changed In 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 Tutorial Triggering Events when a Field is Changed 22 Element Parameters Purpose Entity Field Description: Past Order Problems Subtab: General ID: _had_order_problems Applies To: Customer:Job To create, go to Setup > Customization > Entity Field > New. Transaction Body Field 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 Description: Past Order Problems Type: Check Box Source List: Entity Subtab: Main Display Type: Locked ID: _had_order_problems Applies To: Sale To create, go to Setup > Customization > Transaction Body Field > New. 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.
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 Item In 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. Element Parameters Purpose Entity Field Description: Service Rep Type: Check Box Subtab: Human Resources Applies To: Employee Transaction Column Field Employee Records Create the Code Description: Service Rep Type: List/Record List/Record: Employee ID: _service_rep Applies To: Sale Item Filter Using: Service Rep Is Checked: True Assign various employees as service reps. 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. To create, go to Setup > Customization > Transaction Column Field > New. 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)
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 Totals In 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 Tutorial Recalculating Field Totals 25 Element Parameters Purpose Item Field Description: Service Item Type: Check Box Subtab: Basic ID: _service_item Applies To: Service Default Checked: True To create, go to Setup > Customization > Item Field > New. Transaction Body Field Item Records 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 Description: Service Bookings Type: Currency Subtab: Main Display Type: Locked ID: _service_bookings Applies To: Sale Designate various existing items as service items. To create, go to Setup > Customization > Transaction Body Field > New. Any new service items created are automatically marked as service items.. 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.
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 Save In 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.
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).
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'; return true;" 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
Code Names by Record Type 29 Code Name Field Name Location 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 Contact Record 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 Names by Record Type 30 Code Name Field Name Location salutation Mr./Ms... general supervisor Supervisor general supervisorphone Supervisor Phone general title Job Title general unsubscribe Unsubscribe general Customer Record 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 Names by Record Type 31 Code Name Field Name Location 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 Employee Record Code Name Field Name Location accountnumber Account general aeic AEIC payfed aliennumber Alien Number hrworkstatus allowance Allowance payfed approvallimit Approval Limit hr
Code Names by Record Type 32 Code Name Field Name Location 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 Names by Record Type 33 Code Name Field Name Location 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 Names by Record Type 34 Event 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 Partner Record 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
Code Names by Record Type 35 Code Name Field Name Location taxidnum Tax ID financial unsubscribe Unsubscribe general url Web Address general Task Record 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 Vendor Record 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 Names by Record Type 36 Code Name Field Name Location 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 Opportunity Record 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 Names by Record Type 37 Code Name Field Name Location Available For 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 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 hrwork status 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 availableoffline Authorized to work until Always Available Offline main balance Balance financial financial hrwork status 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 main
Code Names by Field Type 39 Code Name Field Name Customer Job Vendor Partner Employee Contact degree Degree hreducation degreedate Date Conferred hreducation department Department general directdeposit education Use Direct Deposit Level of Education dd hreducation email E-Mail general general general general general general employeestatus Employee hr Status 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 extra Default Expense Account Extra Withholding financial payfed fax Fax general general general general general general fedstatus Filing Status payfed fedunemp fedwith Federal Unemploymen t Federal Withholding payfed 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 hiredate Hire Date hr access homephone Home Phone general general
Code Names by Field Type 40 Code Name Field Name Customer Job Vendor Partner Employee Contact i9verified I-9 Verified hrwork status image Image general general general general general general inheritiprules Inherit IP Rules from Company access initials Initials general ipaddressrule IP Address Restriction is1099eligible 1099 Eligible financial isaccountant Make this my FREE accountant access 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 lastvisit Last Review Date 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 hr
Code Names by Field Type 41 Code Name Field Name Customer Job Vendor Partner Employee Contact nextreviewdate Next Review Date 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 pricelevel Price Level financial printoncheckas Print On Check As probability Probability main projectedenddate referrer Projected End Date Referrer (1st Visit) financial general general general web financial releasedate Release Date hr reminderdays Reminder Days financial resalenumber Resale Number financial residentstatus Resident Status hrwork status salesrep Sales Rep general salutation Mr./Ms... general general sendemail Send Notification E- mail shippingitem Shipping Item financial access access access access socialsecurity Social Security payfed socialsecuritynum ber Social Security startdate Start Date financial financial hr hr
Code Names by Field Type 42 Code Name Field Name Customer Job Vendor Partner Employee Contact subpartnerlogin Can give login access To Subpartners access supervisor Supervisor hr general supervisorphone Supervisor general Phone taxable Taxable financial taxidnum Tax ID financial general taxitem Tax Item financial template Template main terminationbydeat h Termination Due To Death 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 hr hrwork status visatype Visa Type hrwork status visits Number of Visits web w4completed W4 Completed payfed weblead Web Lead general CRM Fields 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
Code Names by Field Type 43 Code Name Field Name Task Event Case Campaign Solution Call completeddate Date Completed main main contact Contact main convcostpercustomer Cost Per Customer Conversion stat cost Cost main costpercustomer Cost Per Customer Acquisition 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 stat
Code Names by Field Type 44 Code Name Field Name Task Event Case Campaign Solution Call profit Profit stat reminderminutes Minutes main remindertype Reminder Type main roi Item Fields Return on Investment 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 Inventory Part Non- Inventory Part Group/Kit/ Assembly stat Discount/ Markup Payment account Account basic basic amortization period amortization template assetaccount availabletopa rtners billingsched ule Amortization Period Amortization Template Asset Account Available To Adv. Partners Billing Schedule basic basic basic basic main main main main main main basic basic basic class Class main main main main main main cogsaccount cost costingmeth od countryofma nufacture COGS Account Purchase Price Costing Method Country of Manufacture basic basic inventory basic inventory basic basic basic basic basic currency Currency basic basic basic Description/ Subtotal
Code Names by Field Type 45 Code Name customform Custom Form main main main main main main daysbeforeex piration deferralacco unt deferredreve nueaccount demandmod ifier Days Before Expiration Deferral Account Deferred Revenue Account Estimated Demand Change basic basic basic basic basic inventory inventory department Department main main main main main main description Description basic basic basic basic displayname Display Name main main main main main expenseacco unt featureddesc ription froogleprodu ctfeed handlingcost incomeaccou nt Expense Account Featured Description Froogle Product Feed Handling Cost Income Account basic specials specials specials store store store basic basic basic basic basic basic internalid Internal ID store store store isdonationite m isdropshipite m isfeatured Variable Amount Drop Ship Item Featured Item store store store basic basic specials specials specials isinactive Inactive main main main main main main isonline Display in main main main Web Site ispretax Apply Before Sales Tax istaxable Taxable basic basic basic isvsoebundle Field Name Is VSOE Bundle? Inventory Part Non- Inventory Part Group/Kit/ Assembly main Discount/ Markup basic Payment Description/ Subtotal
Code Names by Field Type 46 Code Name itemid Item Name/ Number main main main main main main leadtime Lead Time inventory inventory liabilityaccou nt Liability Account basic location Location main main main main main main manufacture r metataghtml Manufacture r Meta Tag HTML basic basic basic store store store mpn MPN basic basic basic nextagcateg ory nextagprodu ctfeed numofallowe ddownloads offersupport NexTag Category NexTag Product Feed Number of Allowed Downloads Offer Support store store store store store store basic main main main onspecial On Special specials specials specials overallquanti typricingtype Calculate Quantity Discounts pricing pricing pricing pagetitle Page Title store store store parent Subitem Of main main main main paymentmet hod preferredloca tion preferredstoc klevel pricinggroup Payment Method Preferred Location Preferred Stock Level Pricing Group inventory inventory inventory inventory pricing pricing pricing printitems Print Items main purchasedes cription purchasetaxc ode Field Name Purchase Description Purchase Tax Code Inventory Part basic basic Non- Inventory Part basic basic Group/Kit/ Assembly Discount/ Markup Payment basic Description/ Subtotal
Code Names by Field Type 47 Code Name quantityavail able quantityback ordered quantitycom mitted quantityonh and quantityonor der quantityprici ngschedule Quantity Available Quantity Back Ordered Quantity Committed Quantity On Hand Quantity On Order Quantity Pricing Schedule inventory inventory inventory inventory inventory inventory inventory inventory inventory inventory pricing pricing pricing rate Rate basic basic basic basic relateditems description reorderpoint Related Items Description Reorder Point relitems relitems relitems inventory residual Residual basic revrecschedu le safetystockle vel salesdescripti on salestaxcode seasonaldem and serialnumber s shippingcost shoppingcat egory shoppingpro ductfeed shopzillacate goryid Field Name Revenue Recognition Template Safety Stock Level Sales Description Sales Tax Code Seasonal Demand Serial Numbers Shipping Cost Shopping Category Shopping Product Feed Shopzilla Category ID Inventory Part inventory basic basic basic inventory basic basic inventory basic basic basic basic inventory inventory Non- Inventory Part inventory inventory basic basic basic store store store store store store store store store Group/Kit/ Assembly Discount/ Markup Payment Description/ Subtotal
Code Names by Field Type 48 Code Name shopzillapro ductfeed specialsdescr iption stockdescript ion storedescript ion storedetailed description storedisplayi mage storedisplayn ame storedisplayt humbnail storeitemte mplate Shopzilla Product Feed Specials Description Stock Description Store Description Detailed Description Item Display Image Store Display Name Item Display Thumbnail Item Drilldown Template Transaction Fields store store store specials specials specials basic basic basic store store store store store store store store store store store store store store store store store store totalvalue Total Value inventory inventory unitstype Units Type basic basic basic usemarginalr ates vendor vendorname Use Marginal Rates Preferred Vendor Vendor Name pricing pricing pricing basic basic main main main main vsoedeferral Deferral vsoepricing vsoepricing vsoepricing vsoedelivere d vsoepermitdi scount Field Name Delivered vsoepricing vsoepricing vsoepricing Permit Discount Inventory Part Non- Inventory Part vsoepricing vsoepricing vsoepricing vsoeprice VSOE Price vsoepricing vsoepricing vsoepricing weight Item Weight basic basic basic Group/Kit/ Assembly Discount/ Markup Payment Description/ Subtotal 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
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
Code Names by Field Type 50 Code Name Field Name Tab 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 quantitybackordere d Back Ordered Off Off quantitycommitted Committed Off Off quantityfulfilled Quantity This Shipment Remittance Slip Return Request - Credit Return Request - Cash quantityonhand On Hand Off Off quantityreceived Received Screen Screen Online Order - Invoice rate Rate Both Both Both Both Off Online Order - Cash Sale Off
Code Names by Field Type 51 Code Name Field Name Tab revrecenddate revrecenddate revrecschedule revrecschedule revrecstartdate revrecstartdate Revenue Recognition End Date Revenue Recognition End Date Revenue Recognition Schedule Revenue Recognition Schedule Revenue Recognition Start Date Revenue Recognition Start Date Remittance Slip Return Request - Credit Return Request - Cash Online Order - Invoice main Off Off Off Off Off Off Off Off main Off Off Off Off Off Off Off Off main Off Off Off Off 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 Online Order - Cash Sale 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 Names by Field Type 52 Code Name Field Name Tab terminmonths Table 2 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 Remittance Slip Return Request - Credit Code Name Field Name Tab Opportunity Drop Ship Purchase Order account Account main Screen Return Request - Cash Shipping Label Online Order - Invoice Return Form Online Order - Cash Sale 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 Statement
Code Names by Field Type 53 Code Name Field Name Tab Opportunity 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 Drop Ship Purchase Order 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 Shipping Label Return Form description Description Screen Both Print duedate Due Date main Both Statement Print Print
Code Names by Field Type 54 Code Name Field Name Tab Opportunity 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 Drop Ship Purchase Order Shipping Label Return Form Statement
Code Names by Field Type 55 Code Name Field Name Tab Opportunity 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 Drop Ship Purchase Order Shipping Label Return Form 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 Print Statement
Code Names by Field Type 56 Code Name Field Name Tab Opportunity Drop Ship Purchase Order Shipping Label Return Form Statement weightedtotal Weighted Total main Screen winlossreason Win/Loss Reason main Screen Table 3 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
Code Names by Field Type 57 Code Name Field Name Tab Packing Slip Picking Ticket 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 quantitybackordere d Back Ordered Off quantitycommitted Committed Print Return Authorization - Cash Return Authorization - Credit Sales Order - Progress Billing
Code Names by Field Type 58 Code Name Field Name Tab 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 revrecschedule revrecschedule revrecstartdate revrecstartdate Revenue Recognition End Date Revenue Recognition Schedule Revenue Recognition Schedule Revenue Recognition Start Date Revenue Recognition Start Date Packing Slip Picking Ticket Print Return Authorization - Cash Return Authorization - Credit Screen Screen Screen main Off Off Off Screen Screen Screen main Off Off Off Sales Order - Progress Billing 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 Names by Field Type 59 Code Name Field Name Tab 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 Table 4 Code Name Field Name Tab Packing Slip Progress Invoice Picking Ticket Sales Order - Cash Sale Return Authorization - Cash Sales Order - Invoice Return Authorization - Credit Canada Finance Charge Sales Order - Progress Billing 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
Code Names by Field Type 60 Code Name Field Name Tab Progress Invoice 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 Sales Order - Cash Sale Sales Order - Invoice Canada Finance Charge 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 Service Invoice
Code Names by Field Type 61 Code Name Field Name Tab entity Entity main Screen Screen Screen Screen Screen event Event Off Off exchangerate Exchange Rate items Screen Screen Screen Screen Screen excludecommissio n Exclude Commissions Progress Invoice Sales Order - Cash Sale Sales Order - Invoice main Screen Screen Canada Finance Charge Service Invoice 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 quantitybackordere d Back Ordered Screen Screen
Code Names by Field Type 62 Code Name Field Name Tab 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 revrecschedule revrecschedule revrecstartdate revrecstartdate Revenue Recognition End Date Revenue Recognition Schedule Revenue Recognition Schedule Revenue Recognition Start Date Revenue Recognition Start Date Progress Invoice Sales Order - Cash Sale Sales Order - Invoice Canada Finance Charge Screen Screen Screen Screen Screen main Off Off Off Off Off Screen Screen Screen Screen Screen main Off Off Off Off Off Service Invoice 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 Names by Field Type 63 Code Name Field Name Tab terminmonths Table 5 Revenue Recognition Term in Months Progress Invoice Sales Order - Cash Sale 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 Product Invoice Off Sales Order - Invoice Off Professional Invoice Canada Finance Charge Credit Memo Service Invoice 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 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 Off
Code Names by Field Type 64 Code Name Field Name Tab billeddate Date Billed Off Off ccapproved Credit Card Approved payment Product Invoice Professional Invoice Credit Memo ccnumber Credit Card # payment Both Cash Sale Screen 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 Names by Field Type 65 Code Name Field Name Tab 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 revrecschedule Revenue Recognition End Date Revenue Recognition Schedule Product Invoice Professional Invoice Credit Memo Screen Screen Screen Screen main Off Off Off Off Cash Sale
Code Names by Field Type 66 Code Name Field Name Tab revrecschedule revrecstartdate revrecstartdate Revenue Recognition Schedule Revenue Recognition Start Date Revenue Recognition Start Date Product Invoice Professional Invoice Credit Memo Screen Screen Screen Screen main Off Off Off Off Cash Sale 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 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 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 Off
Code Names by Field Type 68 Code Name Field Name Tab Cash Refund Estimate Purchase Order 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 Finance Charge 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 Names by Field Type 69 Code Name Field Name Tab Cash Refund Estimate 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 revrecschedule revrecschedule revrecstartdate revrecstartdate Revenue Recognition End Date Revenue Recognition Schedule Revenue Recognition Schedule Revenue Recognition Start Date Revenue Recognition Start Date Screen main Off Off Screen main Off Off Screen Purchase Order 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 Finance Charge Screen Screen Screen
Code Names by Field Type 70 Code Name Field Name Tab Cash Refund Estimate Purchase Order Finance Charge 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
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
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. Discount if (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 rate if( usecustomerdiscount ) alert("discount level not approved, resetting to Customer
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 )
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;
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 total var 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));
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')); else return 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); else return 0; //=====================================================