top of page

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,000

Decoding ServiceNow Record Producers: How to Access Your Variables in Scripts

Updated: Mar 26


ServiceNow Record Producers offer a user-friendly interface for submitting requests for services, information, or assistance. As a ServiceNow developer, you'll often need to write scripts within these producers to automate actions based on the user's input. A fundamental aspect of this scripting is knowing how to correctly access the values users provide through the variables defined on the Record Producer form. This article will provide a clear and concise explanation of the official method for accessing these variables within your ServiceNow Record Producer scripts.


Navigating the World of Record Producer Scripting

When building automation within ServiceNow, Record Producers act as the entry point for many user interactions. They present a simplified form with specific questions (variables) designed to gather the necessary information to fulfill a request. Once the user submits the form, the defined script within the Record Producer takes over to process this information, typically by creating a new record in a designated table (like Incident, Request, or others). To effectively automate this process, your script needs to be able to read the values entered by the user in these variables.


The Official Way to Access Record Producer Variables

If you've worked with ServiceNow Catalog Items, you might be familiar with using the current object to access variable values. However, when dealing with Record Producers, the syntax is slightly different. The officially supported and correct method for accessing variables inside a Record Producer script is through the producer object.


Understanding the producer Object

Within the script of a ServiceNow Record Producer, the producer object acts as a container holding all the variables defined on the Record Producer form. You can access the value of a specific variable by using the producer object followed by a dot (.) and then the name of the variable.

Syntax:

producer.<variable_name>;

Replace <variable_name> with the actual name of the variable as defined in the "Variables" section of your Record Producer record in ServiceNow.


Example:

Let's say you have a Record Producer for reporting a new issue. You've defined a variable named "issue_description" where the user can provide details about the problem. To access the value entered by the user in this variable within your Record Producer script, you would use the following code:

var issueDetails = producer.issue_description;
gs.info("User reported issue: " + issueDetails);

This code snippet retrieves the text entered by the user in the "issue_description" variable and logs it. You can then use this value to populate fields on the record being created, trigger workflows, or perform other automated actions.


Practical Applications of Accessing Record Producer Variables

Knowing how to access variables using the producer object is fundamental for various scripting tasks within Record Producers:

  • Setting Field Values on the Created Record: You can use the values from the Record Producer's variables to directly populate fields on the new record being created.

    For example:

current.short_description = producer.issue_summary; 
current.description = producer.issue_details; 
current.caller_id = gs.getUserID();
  • Conditional Logic: You can use the values of variables to control the flow of your script.

    For instance:

if (producer.priority === 'High') { 
	current.priority = 1; 
} else { 
	current.priority = 3; 
}
  • Integration with Other Systems: You might use the variable values to pass data to external systems through integrations.


Distinguishing Record Producers from Catalog Items

It's important to remember that while both Record Producers and Catalog Items are part of the ServiceNow Service Catalog, they handle variable access in their scripts differently. In Catalog Item scripts, you typically use the current object to access variable values. The current object in a Catalog Item script refers to the Request Item (sc_req_item) being processed.

In contrast, within a Record Producer script, current refers to the target record that is being created (e.g., an Incident record if the Record Producer is configured to create incidents). Therefore, to access the variables from the Record Producer itself, you must use the producer object.


Conclusion: Mastering Variable Access in Record Producers

Successfully accessing variable values within your ServiceNow Record Producer scripts is crucial for building effective and automated service request processes. By consistently using the producer.<variable_name> syntax, you ensure your scripts correctly retrieve the information provided by users, enabling you to automate record creation, implement conditional logic, and integrate with other parts of your ServiceNow environment. Remember the key distinction between Record Producers and Catalog Items when accessing variables in your scripts to avoid confusion and ensure your automation works as intended.

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,000

CONTACT

New Zealand HQ

Integrated Knowledge Consulting Office

Level 3, 93 Grafton Road

Auckland

South Korea

Integrated Knowledge Consulting Office

BMY역삼타워 6층

서울특별시 강남구 역삼동 678-10번지

 

info@ikconsulting.com

Thanks for submitting!

  • LinkedIn Social Icon

© Copyright 2025 Integrated Knowledge Consulting. All rights reserved.

bottom of page