to create exact copy of a catalog item with my own sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:21 AM
Hi, I have a requirement where I need to make a copy of the catalog items and its complete related data [ all variables / catalog client scripts] , but the copied catalog item should have sysid given by me.
with below script , I am able to create blank catalog item with the given sysid, but i want to make it a copy of another catalog item.
//var now_GR = new GlideRecord('cat_item');
//now_GR.setValue('short_description', 'The third floor printer is broken'); //now_GR.setNewGuidValue('eb4636ca6f6d31005be8883e6b3ee333');
//now_GR.insert();
//gs.info(now_GR.getValue('sys_id'));
can someone pls help me with this query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:32 AM
so basically you want to copy catalog item with all stuff i.e. variables, variable set, catalog client script or catalog UI policy
what's your business requirement to copy?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 10:48 AM
Business requirement is:
we have written ATF testcases on catalog items which are sysid specific.
After integration, we may import catalog items with the same name but sysid will change and old catalog items may get deleted. In this scenario ATF test cases may fail.
So, we want to clone newly arrived catalog items with the old sysids.
Requesting you to help me with this issue.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:34 AM
Did you try to use the OOB Copy UI action on your catalog item?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 10:45 AM
Hi @Ankur Bawiskar
Happy to see your reply.
I wish to create newly created catalog item with the given sysid.
For example: In the below script , it creates a catalog item with the given sysid-- "eb4636ca6f6d31005be8883e6b3ee333"
//var now_GR = new GlideRecord('cat_item');
//now_GR.setValue('short_description', 'The third floor printer is broken'); //now_GR.setNewGuidValue('eb4636ca6f6d31005be8883e6b3ee333');
//now_GR.insert();
//gs.info(now_GR.getValue('sys_id'));
Requesting you to help me with this regards.
thanks and appreciate you for your help