- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 06:38 AM
Hi ,
I am trying to create a variable set that is visible only on sc_task, when the task is closed, it should pull the recurring price value mentioned when the catalog item is created (sc_cat_item). How to acieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 02:28 AM
Hi,
ok so in the run script after the task is complete the script is added
please find the below code
Ensure you add current.setWorkflow(false);
current.variables.recurring_price = current.cat_item.recurring_price.toString();
current.setWorkflow(false);
current.update();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 01:18 AM
Hi,
Can you share screenshot where in workflow you wrote that line?
you should set the value once task is closed; So I though you must be using after update BR on sc_task table
Please use after update BR on sc_task table
BR Condition: current.request_item.cat_item == 'yourCatalogItemSysId' && State is Closed
Script:
var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item);
// while setting the value use setWorkflow(false) to avoid triggering BR
ritm.variables.recurring_price = ritm.cat_item.recurring_price.toString();
ritm.setWorkflow(false);
ritm.update();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 11:35 PM
Hi,
out of the box there is this business rule which restricts updating variable on RITM
BR Name: Disallow variable edit on RITM
URL: https://instanceName.service-now.com/nav_to.do?uri=sys_script.do?sys_id=d3a6ded24f331200fc11fa218110c771
For making this update work; please use this logic i.e. setWorkflow(false)
I assume BR is on sc_task table and proper condition is set i.e. it triggers only for your catalog item and when state changes to closed
Script below should work
// query for ritm table
var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item);
// while setting the value use setWorkflow(false) to avoid triggering BR
ritm.variables.recurring_price = ritm.cat_item.recurring_price.toString();
ritm.setWorkflow(false);
ritm.update();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 01:59 AM
Can i not achieve this from workflow, when the task is complete.We already have a generic workflow so can i add a runscript ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 03:41 AM
Hi,
replied to your comment where you mentioned the screenshot
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 02:20 AM
Hi We are trying to achieve this on SCTASK. Since it was mentioned not possibel on SCTASK we tried in RITM> Requirement is for SCTASK