- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 07:52 AM
Dear all,
I have date field on catalog item form which I want to query with existing date.
For that I tried like below-
var a = new GlideRecord('sc_req_item');
a.addQuery('cat_item.variables.date_variable',gs.now());
a.query();
I'm not able to think of some another way to query and this one is not working.
Could someone please help me understanding how we can do this?
Regards,
Surendra
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 08:09 AM
you can query like this
give the variable sysId there
var a = new GlideRecord('sc_req_item');
a.addQuery('variables.sysId',gs.now());
a.query();
Generic Approach:
You can form the query from the table list and then copy the query and then use it
Select the Variables -> Select your catalog item -> Select your variable -> value to search
For me it looked like this
a.addEncodedQuery('variables.9415cd6f0750ec90540bf2508c1ed042=testing');
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
11-11-2020 08:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 08:09 AM
Hi Pranav,
Basically requirement is, I have date field on RITM form where user can enter only future dates.
and once that date has reached I want to create new RITM based on current RITM.
For that , I'm querying RITM table, querying with that perticular catalog item , and additionally I want to check if that date has reached or not.
For that I want to query that date with gs.now
can we do it ?
Regards,
Surendra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 08:20 AM
So you are comparing with a already existing ritm with same catalog item.
If that's the case use this script
var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item',current.cat_item); //This will filter based on the same item and you can add more query filters
gr.query();
if(gr.next()){
//your code
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 08:09 AM
you can query like this
give the variable sysId there
var a = new GlideRecord('sc_req_item');
a.addQuery('variables.sysId',gs.now());
a.query();
Generic Approach:
You can form the query from the table list and then copy the query and then use it
Select the Variables -> Select your catalog item -> Select your variable -> value to search
For me it looked like this
a.addEncodedQuery('variables.9415cd6f0750ec90540bf2508c1ed042=testing');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader