- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
I ran into a snag while updating my Incident record producer. When a user chooses a category while filling out the incident form, it generates another question (a "subcategory type"). I was able to map the Hardware question to the sub_category_type field, but it will not allow me to map the other questions to the same field. Does this have to be scripted? Please see screenshot.
Ex., User chooses Hardware under the Category menu --- generates the question "What type of hardware...."
User chooses Software from under the Category menu -- generates the question "What type of Software...."
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi @Menalik,
you can use the script field on the record producer record:
current.backend_field = producer.portal_field; //to get sys ID
current.backend_field = producer.portal_field.getDisplayValue(); //to get string you can the the whole magics in that field, and Zurich brought option for post-submission script as well.
I have there this (ugly) code which I will re-write one day:
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
@Menalik ,
You can’t natively map more than one Catalog variable to the same target field using the Map to field checkbox (i.e. multiple variables to one field won’t work OOB).......but you can handle this in the Record Producer script by manually building the logic, for example, checking which variable is filled or concatenating multiple variable values (e.g. current.sub_category = producer.var_hw + producer.var_sw;) in the script section so the correct question map into the one field you want.......
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Menalik ,
To map multiple questions (variables) from a ServiceNow record producer to a single field, you must use record producer scripting to consolidate the variable values into a single string before assigning them to the current object's field. Alternatively, if you want to map multiple fields from the record producer's target table to different fields on the produced record, you would typically use the "Map to field" option on each variable.
Using Scripting to Map Multiple Variables to One Field
This is the standard method for combining information from several user inputs into a single field, such as a detailed "Description" field.
- Open: your record producer in ServiceNow.
- Scroll: to the "Advanced" section and open the "Script" tab.
- Create: a string variable (e.g., description = "";) to hold the combined values.
- Use: producer.variableName to access the value of each variable you want to include.
- Concatenate: the variable values into your string variable, adding line breaks (\n) or other separators for readability. For example:
description += "Label: " + producer.variable_name + "\n"; - Assign: the final combined string to the target field using current.fieldName = description;.
Using "Map to field" for Individual Variables
If your goal is to assign the value of a single question to a specific field on the target record, you'll use the "Map to field" option on the individual variable.
- Open: the specific variable you want to map within the record producer.
- Check: the "Map to field" checkbox.
- Select: the appropriate field from the dropdown list that corresponds to a field on the target table.
- Repeat: this process for each variable you want to map to a different field.
This allows you to populate different fields on the created record based on individual questions in the record producer.
If you found my response helpful, could you please mark it as ‘Accept as Solution’ and ‘Helpful’? This small action goes a long way in helping other community members find the right answers more easily and supports the community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi @Menalik,
you can use the script field on the record producer record:
current.backend_field = producer.portal_field; //to get sys ID
current.backend_field = producer.portal_field.getDisplayValue(); //to get string you can the the whole magics in that field, and Zurich brought option for post-submission script as well.
I have there this (ugly) code which I will re-write one day:
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
@Menalik ,
You can’t natively map more than one Catalog variable to the same target field using the Map to field checkbox (i.e. multiple variables to one field won’t work OOB).......but you can handle this in the Record Producer script by manually building the logic, for example, checking which variable is filled or concatenating multiple variable values (e.g. current.sub_category = producer.var_hw + producer.var_sw;) in the script section so the correct question map into the one field you want.......
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Menalik ,
To map multiple questions (variables) from a ServiceNow record producer to a single field, you must use record producer scripting to consolidate the variable values into a single string before assigning them to the current object's field. Alternatively, if you want to map multiple fields from the record producer's target table to different fields on the produced record, you would typically use the "Map to field" option on each variable.
Using Scripting to Map Multiple Variables to One Field
This is the standard method for combining information from several user inputs into a single field, such as a detailed "Description" field.
- Open: your record producer in ServiceNow.
- Scroll: to the "Advanced" section and open the "Script" tab.
- Create: a string variable (e.g., description = "";) to hold the combined values.
- Use: producer.variableName to access the value of each variable you want to include.
- Concatenate: the variable values into your string variable, adding line breaks (\n) or other separators for readability. For example:
description += "Label: " + producer.variable_name + "\n"; - Assign: the final combined string to the target field using current.fieldName = description;.
Using "Map to field" for Individual Variables
If your goal is to assign the value of a single question to a specific field on the target record, you'll use the "Map to field" option on the individual variable.
- Open: the specific variable you want to map within the record producer.
- Check: the "Map to field" checkbox.
- Select: the appropriate field from the dropdown list that corresponds to a field on the target table.
- Repeat: this process for each variable you want to map to a different field.
This allows you to populate different fields on the created record based on individual questions in the record producer.
If you found my response helpful, could you please mark it as ‘Accept as Solution’ and ‘Helpful’? This small action goes a long way in helping other community members find the right answers more easily and supports the community.
