How can I save the value of the task variable in the ritm?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi all,
I have a workflow, inside which I've inserted the 'Catalog Task' box. The variables for my catalog item are contained in the task. In the ritm, I enter the task and find the variable, enter a value, and save it. I return to the ritm and save it as well. If I return to the task and refresh the page, the value of the variable in the task returns to -None-. If I refresh the ritm, instead of saving it, the variable value remains. How can I save the value of the task variable in the ritm when it is saved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
yes you need to reload the RITM form after you saved the task with that variable, then only the value will be refreshed on RITM form.
But if you save the RITM the variable value set from task form will be overriden because on RITM form you haven't refreshed yet and it's still None/Empty.
As per your comment this variable is not shown on RITM form then how are you hiding it?
Any UI policy? if yes then is that UI policy clearing the value when it runs with reverse condition?
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
3 weeks ago
yes, there is a UI policy that controls all the fields that should not appear on the RITM, and this is set to reverse if false, I tried to disable it but it still does not save the value in the task variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I already informed the OOTB behavior.
Please debug further as there should be something which is causing this.
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
a month ago
Hi @screscenzi ,
Solution: Use a Business Rule for Sync
To ensure that changes made on the catalog task are persisted back to the RITM, implement a Business Rule on the sc_task table.
Table: sc_task
When to run: Async, on Update
Condition: Filter it to run only on relevant tasks (e.g. specific catalog item or task via current.request_item)
(function executeRule(current, previous /* null when async */) {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.request_item);
gr.query();
if (gr.next()) {
// Copy the variable from task to RITM
gr.variables.YOUR_VARIABLE_NAME = current.variables.YOUR_VARIABLE_NAME;
gr.update();
}
})(current, previous);
If you have a variable that can be updated on RITM and SCTASK records, then you need two Business Rules, one on the sc_req_item table, and one on the sc_task table....
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
Sorry, I tried but it doesn't work, in fact I save it on the ritm, and the variable is in the catalog item that goes on the ritm. I inserted it (the variable) in sc_task through the workflow in the catalog task box, in the 'add variables' section.