- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2022 11:05 AM
Hello Guys,
For all existing catalog tasks, I want to copy "request_item.requested_for" field on RITM to "user" (custom) field on ScTasks. How can I achieve this? and How does the script look like?
We have few hundreds of catalog tasks, So, I wanted to do a bulk update using script.
Any help is appreciated.
Thanks,
Ben.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 12:27 PM
Hey Ben,
Just a quick check, in the list view of sc_task table, group by u_end_user field and confirm if all are under empty.
Also, added a new line to the code, please try
var a = "u_end_user=NULL";
var b = "parent.ref_sc_req_item.requested_forISNOTEMPTY";
var sc = new GlideRecord('sc_task');
sc.addEncodedQuery(a);
sc.addEncodedQuery(b);
sc.setLimit(10);
sc.query();
while(sc.next())
{
sc.u_end_user = sc.parent.ref_sc_req_item.requested_for;
sc.update();
sc.setWorkflow(false);
}
Regards,
Abhinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:08 PM
Great, Thanks for your detailed explanation and continous support.
Ben.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:30 PM
Hello,
Thanks for your assistance, but I don't think a jab at the other forum posters was needed and their forum level has nothing to do with this.
With that said, the author could have provided more information up front, which would have expedited the response as well as providing more information in their responses instead of "it's not working".
You should be able to easily access the requested_for field on the related request item of the catalog task just fine per what was suggested by others. If it wasn't working for the author, then there was most likely more to all of this than what others would have known. Your suggestion of going through the parent field on the catalog task instead and then referencing the request level of the requested item and that request's requested_for field was what was already suggested by others, you just did it another way.
In any case, I'm glad the issue was resolved, but I felt the need to reply after reading your response and the statement positioned towards the other people replying as I felt that was unnecessary. It took longer, not because of their responses and lack of knowledge, but because of the author not providing more information in much of their responses.
Ben, in the future, I hope you can see how providing more in your responses than just "it's not working", can help us...help you.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 11:15 AM
Apologies Allen, if my statement looked like I am taking a jab on any expert. That was not my intention, my whole emphasis was "sometimes dot walking gets confusing" and I used their experience/levels as an example to support my statement.
Also, I will still repeat, that it was suppose to be a straight forward solution but the unknowns lead the delay. I will edit my previous comment because I do respect your expertise and knowledge and if you say it sounds irrelevant than I believe you. I am new to SNOW and this community as an engaging member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 06:20 AM
hello Ben,
you can try below script
var sc = new GlideRecord('sc_task');
sc.addQuery('custom_field_name','!=','');
sc.query();
while(sc.next())
{
sc.your_customer_user_field_name =sc.request_item.request.requested_for;
sc.update();
}
please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 07:14 AM
Hello Mohith,
Script did not work, any other alternative?
Thanks,
Ben.