---
sourceDocument: Australia API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/api-reference

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# LeadAPIHelperOOB - Scoped

# LeadAPIHelperOOB - Scoped {#ariaid-title1}

Release version: Australia  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read  
The LeadAPIHelperOOB script include provides helper methods called by the lead REST API to perform various functions, such as converting a set of lead records from a GlideRecord object into
a JSON array or JSON object and transforming fields within a lead object.

If you want to customize these helper functions, override the methods in this script include in the LeadAPIHelper script include. The names of the methods that you are overriding in the
LeadAPIHelper script include must be the same as those in the LeadAPIHelperOOB script include file.

This API is provided within the `sn_lead_mgmt_core` namespace. To access the API, the Lead Management Data Model (sn_lead_mgmt_core) plugin must be activated on the instance, and the calling
user must have the sn_lead_mgmt_core.lead_integrator role.

For additional information on Lead Management, see [Using Lead Management](https://www.servicenow.com/docs/access?context=lead-management-using&version=australia&pubname=australia-order-management&ft:locale=en-US).

## LeadAPIHelperOOB - getJSONFromGR(GlideRecord gr, Array fields) {#ariaid-title2}

Converts a GlideRecord object into a JSON object. This method iterates over the fields of the GlideRecord, checks their types, and appropriately formats their values into a JSON-compatible structure.
{#LAH-getJSONFromGR_GR_A__table_wfp_p1z_ydc__entry__3}

| Name | Type | Description |
|-|-|-|
| gr | GlideRecord | GlideRecord object to convert to a JSON object. |
| fields | Array | Optional. Comma-separated field names to include in the JSON object. These names must exactly match the names in the lead record. For example:  `["account", "first_name", "do_not_call", "lead_line_items"]` Note: If the fields parameter is null or contains the value `"lead_line_items"`, the method fetches each associated line item record, including all fields of the line item. This method only supports converting individual fields from the Lead \[sn_lead_mgmt_core_lead\] table, not the Lead Line Item \[sn_lead_mgmt_core_lead_line_item\] table. If you specify a specific field from the Lead Line Item table, it is ignored. Default: All lead record fields are included in the JSON object. |
[Table 1. Parameters]

{#LAH-getJSONFromGR_GR_A__table_wfp_p1z_ydc} {#LAH-getJSONFromGR_GR_A__table_xfp_p1z_ydc__entry__2}

| Type | Description |
|-|-|
| JSON object | JSON object that contains the fields from the specified GlideRecord. Each field in the GlideRecord is converted to a key-value pair. Special handling is applied for reference fields, choice fields, date-time fields, and other specific data types to ensure they are correctly formatted. |
[Table 2. Returns]

{#LAH-getJSONFromGR_GR_A__table_xfp_p1z_ydc}  
The following code example shows where to add your custom code for the getJsonFromGR() method in the LeadAPIHelper script include.

    var LeadAPIHelper = Class.create(); 
    LeadAPIHelper.prototype = Object.extendsObject(LeadAPIHelperOOB, {

    // Define overriding functions here
    getJSONFromGR: function(gr, fields) {

    // Add your custom code here
    },

    type: 'LeadAPIHelper'
    });

## LeadAPIHelperOOB - getLeadsJSON(GlideRecord leadsGr, Array fields) {#ariaid-title3}

Converts a set of lead records from a GlideRecord object to a JSON array. You must specify the lead record fields that you want included in the JSON array.
{#LAH-getLeadsJSON_GR_A__table_d41_qvy_ydc__entry__3}

| Name | Type | Description |
|-|-|-|
| leadsGr | GlideRecord | GlideRecord object containing the lead records to convert to JSON. Table: Lead \[sn_lead_mgmt-core_lead\] |
| fields | Array | Comma-separated field names to include in the JSON object. These names must exactly match the names in the lead record. For example:  `["account", "first_name", "do_not_call", "lead_line_items"]` Note: If the fields parameter is null or contains the value `"lead_line_items"`, the method fetches each associated line item record, including all fields of the line item. This method only supports converting individual fields from the Lead \[sn_lead_mgmt_core_lead\] table, not the Lead Line Item \[sn_lead_mgmt_core_lead_line_item\] table. If you specify a specific field from the Lead Line Item table, it is ignored. |
[Table 3. Parameters]

{#LAH-getLeadsJSON_GR_A__table_d41_qvy_ydc} {#LAH-getLeadsJSON_GR_A__table_e41_qvy_ydc__entry__2}

| Type | Description |
|-|-|
| Array of JSON objects | Each object represents a lead containing the specified fields. If applicable, it also includes an array of lead line item objects for every lead. Each field in the GlideRecord is converted to a key-value pair. Special handling is applied for reference fields, choice fields, date-time fields, and other specific data types to ensure they are correctly formatted. |
[Table 4. Returns]

{#LAH-getLeadsJSON_GR_A__table_e41_qvy_ydc}  
The following code example shows where to add your custom code for the getLeadsJson() method in the LeadAPIHelper script include.

    var LeadAPIHelper = Class.create();
    LeadAPIHelper.prototype = Object.extendsObject(LeadAPIHelperOOB, { 

    // Define overriding functions here 
    getLeadsJson: function(leadsGR, fields) {

    // Add your custom code here
    }, 

    type: 'LeadAPIHelper' 
    }); 

## LeadAPIHelperOOB - getTransformedLeadObject(Object leadObject) {#ariaid-title4}

Transforms the specified lead object.
This transformation includes:

* Removing ignored fields.
* Converting reference fields to their  associated values, such as a sys_id.
* Combining work notes texts into a comma-separated string.
* Validating the account, contact, and consumer fields. The values of account, contact, and consumer are ignored if both account and consumer contain values.
{#LAH-getTransformedLeadObject_O__ul_oyl_lxq_12c}
{#LAH-getTransformedLeadObject_O__table_vpc_l2z_ydc__entry__3}

| Name | Type | Description |
|-|-|-|
| leadObject | Object | Lead object to transform. This object contains details of the lead and its related lead line items. |
[Table 5. Parameters]

{#LAH-getTransformedLeadObject_O__table_vpc_l2z_ydc} {#LAH-getTransformedLeadObject_O__table_wpc_l2z_ydc__entry__2}

| Type | Description |
|-|-|
| Object | Transformed lead object. |
[Table 6. Returns]

{#LAH-getTransformedLeadObject_O__table_wpc_l2z_ydc}  
The following code example shows where to add your custom code for the getTransformedLeadObject() method in the LeadAPIHelper script include.

    var LeadAPIHelper = Class.create();

    LeadAPIHelper.prototype = Object.extendsObject(LeadAPIHelperOOB, {

    // Define overriding functions here 
    getTransformedLeadObject: function(leadObject) { 

    // Add your custom code here
    }, 

    type: 'LeadAPIHelper'
    }); 


