
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 04:13 PM
Hi,
I am new to ServiceNow and have just been tasked with something I don't know how I would accomplish.
Background of the Problem: I need to accomplish versioning on the catalog items on a related list. So we have a Service Catalog Registry as the Parent and Catalog Items as the Related Lists to the parent. My job is whenever a user clicks on NEW VERSION UI Action button, it should automatically query the related list (for Catalog Items) and search for the latest active Catalog Item. In this case it is with the Name = 'Test 3'. It should copy all the values for that table and its related variables and create a new catalog item (with copied values). And make the Test 3 as inactive.
I could accomplish this behavior by enabling the user to click on the active catalog item and then when the user click on NEW VERSION , it automatically copies the contents and make this as inactive by using this script:
But this puts an extra step on the customer to select a Related record and then hit NEW VERSION and the solution is not user-friendly.
Does anyone have a pointer to how I can accomplish it ? Basically these questions :
1) Which API should I use to query the related list ?
2) How would add a condition in the query to fetch me the most current active record ? In this case active=true
3) How can i make the current record as INACTIVE ?
4) How can I redirect the URL to the new catalog item ?
5) A code snippet for the same if someone has already done such type of problem ? This would be really helpful. Thanks a ton for your help 🙂
Let me know if you have any questions/concerns ?
Thanks
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2018 12:26 PM
You could do a GlideRecord query in you UI Action to query for the active item and then copy it and set it to active = false.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 02:24 PM
Greetings Abhishek,
The UI Action has access to the parent record, this allows you to build your query. So on line 6 you can replace your sys_id with parent.getValue('sys_id')
I would not try to script the create a new catalog item from scratch here.
-Andrew Barnes
Flow Designer London Learning Module: http://bit.ly/2ypjKUX

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 02:47 PM
Hi Andrew,
Thanks for replying. By new record, I meant to say 'redirect the user to the new form without any copied fields.' Which line of code should I use ?
Thanks!