- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2021 03:41 AM
So basically I have used gr.addEncodedQuery for getting the sys_id for a catalog item from sc_cat_item table.
GR.addEncodedQuery('cat_item=5ef6781b53131300afffddeeff7b1277');
Now there is an error from TPP instance certification test that says that you have to use gs.getproperty().
This is the error:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2021 03:53 AM
Hi,
That's correct it is not best practice to use hard-coded sys_id
1) Create system property of type string and store the sys_id
2) then use it in your script
GR.addEncodedQuery('cat_item=' + gs.getProperty('my_sysId'));
1) Visit sys_properties.list
2) then create new
3) give name
4) give value
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-21-2021 03:53 AM
Hi,
That's correct it is not best practice to use hard-coded sys_id
1) Create system property of type string and store the sys_id
2) then use it in your script
GR.addEncodedQuery('cat_item=' + gs.getProperty('my_sysId'));
1) Visit sys_properties.list
2) then create new
3) give name
4) give value
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
02-28-2024 07:46 AM
@Ankur Bawiskar I also have a similar requirement and trying with the below script:
var CenterCategoryIds = gs.getProperty("my.catalog.items");
var gp = new GlideRecord('sysapproval_approver');
//gp.addEncodedQuery('sysapproval=083619c787604690a29a2f0d8bbb35c9^u_approval_type=Line Manager^u_requested_items.cat_item=' + '87d0c77adb810898541a62eb0b961972');
gp.addEncodedQuery('sysapproval=083619c787604690a29a2f0d8bbb35c9^u_approval_type=Line Manager^u_requested_items.cat_item=' + CenterCategoryIds);
gp.query();
while (gp.next())
{
gs.print('HELLO WORLD');
}
However, the moment I replace the sys id with the system property, my script is failing.
Can you please help me on this.
Thank you,
Ayshee Chattopadhyay