Lets say I want to make this query in a script:
First example:
Easiest way would be just to right click and choose copy query and put it in the variable encque. Then writing a script like this:var encque = 'active=true^assignment_groupISEMPTY^NQassignment_group=bd6973270f6f31401314715ce1050ec3^ORpriority>2';
var gr = new GlideRecord('incident');
gr.addEncodedQuery(encque);
gr.query();
while (gr.next() {
//Do some fun stuff
}
This might be a fast way, but it would be not so fast when you are going to start to modify the encoded query.
Second example:
Now, let's say you want to split up the condition so you at least have those separated. Lets keep it to encoded queries and see how we can do it then. Still fast to make since you can do the "copy query" and a bit easier to modify to you have divided the total query in two variables.
First do the first condition set.
Right click and copy query.
Save this in the variable encque1.
var encque1 = 'active=true^assignment_groupISEMPTY';
Then you create the second set.
Right click and copy query.
Save this in the variable encque2.
var encque2 = 'assignment_group=bd6973270f6f31401314715ce1050ec3^ORpriority>2';
The script then looks like this:
var gr = new GlideRecord('incident');
gr.addEncodedQuery(encque1);
//Here you have to add ^NQ to get the "OR all of these conditions must be met
gr.addEncodedQuery('^NQ' + encque2);
gr.query();
while (gr.next() {
//Do some fun stuff
}
gr.addEncodedQuery(encque1);
//Here you have to add ^NQ to get the "OR all of these conditions must be met
gr.addEncodedQuery('^NQ' + encque2);
gr.query();
while (gr.next() {
//Do some fun stuff
}
Third example:
Now let's do this thing without any "copy query". It takes some more thinking creating, but it much easier to modify and understand when you look at the code.
//First condition set
var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.addQuery('assignment_group','');
//Second condition set
var gr2 = new GlideRecord('incident');
gr2.addQuery('assignment_group','bd6973270f6f31401314715ce1050ec3').addOrCondition('priority','>','2');
//Now lets nestle them together with the ^NQ
gr.addEncodedQuery('^NQ' + gr2.getEncodedQuery());
gr.query();
while (gr.next() {
//Do some fun stuff
}
Hope this will give you some idea's of what you can do :)
//Göran
while (gr.next() {
//Do some fun stuff
}
Hope this will give you some idea's of what you can do :)
//Göran
Inga kommentarer:
Skicka en kommentar