How to check multiple fields(fields like : category, subcategory, sub process) in Glide Record and with examples?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 04:54 AM
How to check multiple fields(fields like : category, subcategory, sub process) in Glide Record and with examples ?
Note : addorcondition i used but not working, please help me.----Thanks , Ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 04:58 AM
Hi,
PFB the example of how addquery and addencodedqueryworks:
In addquery you will either use 'addor' condition or addquery.In add query you will need to write multiple query lines on the basis of data you want to fetchSyntax is
var gr = GlideRecord('incident');
gr.addQuery('state','3');
gr.query();
while(gr.next()){
gs.print(gr.caller);
}
In addencodedquery, you can pass multiple values from one query and fetch results, howver it is recommended not to use highly complex encoded queries.Syntax is :
var filterQuery = "active=true^sys_created_on>javascript:gs.dateGenerate('2015-09-01','23:59:59')^state=3"
var gr = GlideRecord('u_updates');
gr.addEncodedQuery(filterQuery);
gr.query();
Mark it as correct/helpful it this helps you
Than you
Regards,
Shubham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 05:50 AM
Hi,
Did you find the solution for this??
Please mark it as correct/helpful if this helps you and close the thread so others can refer.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 05:00 AM
Hi,
You can use addorcondition to check for multiple fields.
Or you can also use addEncodedQuery()
For more details refer the below link.
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_ScopedGlideRecordAddEncodedQuery_String
Or you can also use addQuery() method to check for multiple fields (for both conditions true)
Please mark correct/helpful if it helps for you.
Regards,
Pooja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 07:13 AM
Thanks for your response,
i will share my code , could you please check once and let me know. Advance thanks.
var gr = new GlideRecord('u_business_app_lookup');
gr.addQuery('u_subcategory',current.variables.u_subcategory).addOrCondition('u_process',current.variables.u_inc_business_process).addOrCondition('u_subprocess',current.variables.u_inc_subprocess);
gr.query();
var test = gr.getEncodedQuery();
if(gr.next()){
gs.log('inside if'+test,'workflow');
if(JSUtil.notNil(gr.getValue('u_assignment_group')))
task.assignment_group = gr.u_assignment_group;
}
Thanks,
Ram