- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2022 02:56 PM
Hi,
I couldn't fine a solution for my requirement. I'm learning scripting.
I want to copy a value from Request [sc_request] table to Catalog Task [sc_task] table. It should happen when the field in the Request table is either updated or inserted.
I have the following in the When to run tab.
This is the script and obviously there is something wrong. I think it is in the gr.addQuery line? Can someone help me with that?
var a = current.work_start;
var gr = new GlideRecord('sc_task')
gr.addQuery('request',current.request)
gr.query();
gr.u_quote_approval_date = a;
gr.update();
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 07:57 AM
Hi,
the BR should be after update on sc_request
Ensure you give correct condition so that the BR triggers
Update script as this
I hope work_start and u_quote_approval_date fields are of same type
var a = current.work_start;
var gr = new GlideRecord('sc_task');
gr.addQuery('request',current.getUniqueValue());
gr.query();
while(gr.next()){
gr.u_quote_approval_date = a;
gr.update();
}
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
‎01-13-2022 03:50 PM
Hi,
You can do this to set when to run:
The table sc_request extends sc_task then you're working with fields of the same table.
Since you're working on the same record, your script can be as simple as this:
Please mark my response as Correct or Helpful, if you find it appropriate.
________________________
Carlos Camacho
https://www.linkedin.com/in/camachojunior
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 07:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 07:57 AM
Hi,
the BR should be after update on sc_request
Ensure you give correct condition so that the BR triggers
Update script as this
I hope work_start and u_quote_approval_date fields are of same type
var a = current.work_start;
var gr = new GlideRecord('sc_task');
gr.addQuery('request',current.getUniqueValue());
gr.query();
while(gr.next()){
gr.u_quote_approval_date = a;
gr.update();
}
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
‎01-14-2022 08:07 AM