- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 03:52 AM - edited 07-04-2025 03:53 AM
For my particular catalog item, i want to make the changes so that once the RITM is raised then all the selcted variable along with their value should be auto populated in RITM description field as mentioned in the below screenshot.
Please provide the script for the same.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 04:23 AM
you can use Workflow run script or after insert business rule on RITM table
var arr = [];
var variables = current.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (label != '' && value != '') {
arr.push(label + ":" + value);
}
}
current.description = arr.join('\n');
current.update(); // use this if you are using after insert BR, don't use this when workflow run script is used
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2025 06:41 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 04:54 AM
Hello @VIKAS MISHRA,
You can create After Insert Business rule like below-
Filter Condition : Item is <Select your catalog item>
Script -
(function executeRule(current, previous /*null when async*/) {
var targetCatalogItemName = 'iPad Pro';// your catalog item
// Only proceed if this RITM belongs to the specified catalog item
if (current.cat_item.name == targetCatalogItemName) {
var ritmDescriptionContent = "--- Submitted Details ---\n"; // Start with a clear header
current.variables.getElements().forEach(function(variableElement) {
var variableQuestion = variableElement.getQuestion();
var varLabel = variableQuestion.getLabel();
var varValue = variableQuestion.getDisplayValue();
// Append to the description only if both label and value are present and not just whitespace
if (varLabel && varValue && varValue.trim() !== '') {
ritmDescriptionContent += varLabel + ": " + varValue.trim() + "\n";
}
});
// Set the RITM's description field
current.description = ritmDescriptionContent.trim();
current.update();
}
})(current, previous);
Output -
Let me know if you have any question.
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 05:02 AM
If you don't want to use scripts and are more comfortable with Flow Desginer
you can do that there too
you would have
Get Catalog Variables
Update Record - RITM
then add Description field
and in the box format how you have it