- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have added a variable editor to the Catalog Task (SCTASK) layout. I have a catalog item: Onboarding. When this catalog item is submitted, its related SCTASK record is created through a workflow.
In the workflow, some catalog tasks are created using the Catalog Task activity, while others are created using scripts.
For the SCTASK records created using the Catalog Task activity, I am able to see the Variable Editor. However, for the tasks created using scripts, the variable editor is not displayed.
Could someone help me understand why the variable editor is not appearing for tasks created via scripts?
Please refer to the workflow screenshot below. Also, here is a snippet from the script used to create the task for reference:
SCTASK created using catalog task element
SCTASK created using script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The Variable Editor formatter is part of the sc_task form out of box, so I'm confused that you 'added' one. In any event, the variables aren't visible on your scripted task because you didn't add any variables in the script! You can use something like this within your for each loop after each task is created:
var ritmVariables = current.variables.getElements();
ritmVariables.forEach(function(ritmVar) {
grTaskVar = new GlideRecord('sc_item_variables_task');
grTaskVar.newRecord();
grTaskVar.task = newTaskId;
grTaskVar.variable = ritmVar.getQuestion().id;
grTaskVar.insert();
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
what was the issue and what you did to resolve that?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
those created from script won't get the variable editor by default
you need to create record into table "sc_item_variables_task"
Script already shared by @Brad Bowman
also check this link
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
