How to parse sysparm_query ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 01:12 AM
Hi all,
let's imagine that I have following query: u_group_item=true^u_parentISEMPTY^u_descriptionLIKEcomp.
Is there a way in ServiceNow how can I get following object or array of key/pair values from filter conditions?
{
u_group_item: true,
u_parent:'',
u_description:comp
}
I do not need operators, only columns and values.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 01:27 AM
Hi Peter,
Try something like below.
var desc = '';
var qry = 'u_group_item=true^u_parentISEMPTY^u_descriptionLIKEcomp.';
var spli_qry = qry.split('^');
var len = spli_qry.length;
for(var i=0; len>i;i++)
{
var spli_rec = spli_qry[i].split('=');
desc += spli_rec[0]+' :'+spli_rec[1]+'\n';
}
alert(desc);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 01:35 AM
Hi Harish,
thanks a lot, I was thinking about parsing like this. It is a little bit more complicated because there is not always only '^' but sometimes also '^EQ' or '^OR'. I admit that this was not a good example .
Also splitting around '=' is not efficient when I have condition like u_parentISEMPTY.
There can occur many cases which should be handled in different ways, I wonder if there is any OOB function which can handle this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 03:20 AM
Not sure is there any OOB script available for this but we can do it script .