ANS-1145 · SUITESCRIPT DEVELOPMENT

How to Script the Lead Source Field on NetSuite Sales Orders?

Understand how to programmatically interact with the lead source field on NetSuite Sales Order records using SuiteScript.

Short answer

The 'leadSource' field on NetSuite Sales Order records is scriptable, allowing for programmatic access and manipulation. Developers can utilize SuiteScript to read or set this field, enabling automation of lead source assignment based on custom business logic. Refer to the NetSuite Records Browser for detailed field properties.

Scenario

NetSuite users often require dynamic control over the Lead Source field on Sales Order records. This typically involves automating the assignment or modification of the lead source based on specific business rules or integrations, rather than manual entry. The challenge lies in confirming the scriptability of this field for custom development.

Solution

Yes, the 'leadSource' field on NetSuite Sales Order records is scriptable. This allows for programmatic access and manipulation of the field using SuiteScript.To confirm the scriptability and retrieve detailed information about the 'leadSource' field, including its internal ID and properties, developers should consult the NetSuite Records Browser. This essential resource provides up-to-date documentation for all standard NetSuite records and their fields.For instance, to set the lead source on a Sales Order using SuiteScript, the following syntax can be used:

javascriptcurrentRecord.setValue({    fieldId: 'leadsource',    value: 'YOUR_LEAD_SOURCE_ID' // Replace with the internal ID of the desired lead source});

Similarly, to retrieve the current lead source value:

javascriptvar leadSourceId = currentRecord.getValue({    fieldId: 'leadsource'});

The internal ID for the Lead Source field on Sales Orders is 'leadsource'.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant