I want to get the catalog tasks which are closed complete based on short description

Sai25
Giga Guru

Hi Team,

I want to get the catalog tasks which are closed complete based on short description. In the IF condition I need to have multiple condition should be added.

When both condition are met I need to enter into the if condition.

Can you please help how to do it.

var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item','c075f9251b153d10c961a9fbbc4bcb8e');
grTask.query();
while (grTask.next()) {

if ((grTask.short_description.includes('Account ID Created In Azure')&& grTask.state == 3) && (grTask.short_description.includes('Azure account creation')&& grTask.state == 3)) {


gs.log("snow===" + grTask.number);
}

//gs.log("Catalog Tasks==="+grTask.number);
}

6 REPLIES 6

Sunny3008
Tera Guru

Hello @Sai25 ,

 

You can try the following code :

 

var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item','c075f9251b153d10c961a9fbbc4bcb8e');
grTask.query();
while (grTask.next()) {
if ((grTask.short_description.toString().includes('Account ID Created In Azure')&& grTask.state == 3) || (grTask.short_description.toString().includes('Azure account creation')&& grTask.state == 3)) {


gs.log("snow===" + grTask.number);
}

//gs.log("Catalog Tasks==="+grTask.number);
}

 

you can use '||' if you want one of condition return true.

 

If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.

Thanks & Regards,

Sunny R

Hi Sunny,

both condition should be satisfied along state value i.e. 3.

When both tasks are closed complete then it should enter into the If condition.

Account ID Created In Azure&& Azure account creation

Hello @Sai25 ,

 

In this case, you can try the following code:

 

var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item','c075f9251b153d10c961a9fbbc4bcb8e');
grTask.addEncodedQuery('state=3^short_descriptionLIKEAccount ID Created In Azure^ORshort_descriptionLIKEAzure account creation')
grTask.query();
if (grTask. getRowCount()==2) {
gs.log("Both Task Is Close");
}else
 gs.log("Both or One of the task is open");

 

 

Let me know if there is any issue or question.

 

If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.

Thanks & Regards,

Sunny R

like this, it could work. Though I would look some better option instead of searching in short description, that could have many proble. Though the script above could help for the Sai