Populate a Catalog Item variable from its corresponding Universal Task short description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 08:31 AM
Scenario:
A catalog item is available for completion on the portal when a Universal Task has a Type = Submit Catalog Item.
Challenge:
Populate the asset name variable (with the asset's display name) from the Universal Task's short description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 06:25 AM
Hello @Basim
You pass the Short Description of a Universal Request.
You extract the asset name (like #274753 HP ProBook x360 435 69) from that description using regex.
You return the extracted name as an output variable from the Custom Action.
You can use this variable later in the Flow Designer.
Please use the below script in custom actionvar inputString = "Guardian Form -#274753 HP ProBook x360 435 \n69-Sietse Radix";
// i just considering as string(hardcode) but you can dynamically handle this by input parameter in custom action like input.inputString // variable that you are using
var regex = /-(#\d+\s[\s\S]*?)\s*-[A-Za-z]+\s[A-Za-z]+/;
var match = inputStr.match(regex);if (match && match[1]) {
return output.asstName // output variable.
var assetName = match[1].trim();
gs.info("Asset Name: " + assetName);
} else {
gs.info("Asset name not found.");
}
and also take help from the below article as well to update catalog item variables.
https://www.servicenow.com/community/servicenow-ai-platform-articles/set-value-of-a-catalog-variable...
https://www.servicenow.com/community/developer-forum/changing-the-type-of-existing-catalog-item-vari...
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank you !!