Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help in checking whether the CI is of a certain CLASS type

Tal5
Giga Guru

Hi everyone, 

I would appreciate any help please with case I am facing.

I want to check whether CI is of a certain CLASS, let's say for  example, Hardware.

If the selected CI is of the appropriate CLASS, I want to set the business service and service offering fields in read only,

I used glideajax, because dot walk in UI Policy doesn't respond as I want

 

client script:

Tal5_0-1711009958700.png

script include:

Tal5_1-1711010118432.png

What do I write in the condition in the last function in the client script
For the process to take place for me?


Thanks to all the helpers

 

1 ACCEPTED SOLUTION

shikhatyagi
Kilo Sage

Hi @Tal5 

 

I will suggest you to create one system property and provide cmdb classes as a comma separated value.

shikhatyagi_0-1711011755010.png

 

Make changes in your script include based on below code:

 

var excludeclasses=gs.getProperty("checkcmdbclass"); // get system property value

var gr=new GlideRecord("cmdb_ci");
gr.addQuery("sys_id","b4fd7c8437201000deeabfc8bcbe5dc1"); // pass cisysid
gr.addQuery("sys_class_name",'IN',excludeclasses);
gr.query();
if(gr.next())
{

return true;
}
else{
return false;
}

 

In client script use:

if (answer == true)

 

 

Please Mark this Helpful and Accepted Solution if it solves your issue.

 

Thanks & Regards,

Shikha Tyagi

View solution in original post

2 REPLIES 2

shikhatyagi
Kilo Sage

Hi @Tal5 

 

I will suggest you to create one system property and provide cmdb classes as a comma separated value.

shikhatyagi_0-1711011755010.png

 

Make changes in your script include based on below code:

 

var excludeclasses=gs.getProperty("checkcmdbclass"); // get system property value

var gr=new GlideRecord("cmdb_ci");
gr.addQuery("sys_id","b4fd7c8437201000deeabfc8bcbe5dc1"); // pass cisysid
gr.addQuery("sys_class_name",'IN',excludeclasses);
gr.query();
if(gr.next())
{

return true;
}
else{
return false;
}

 

In client script use:

if (answer == true)

 

 

Please Mark this Helpful and Accepted Solution if it solves your issue.

 

Thanks & Regards,

Shikha Tyagi

Tal5
Giga Guru

Thank you very much for your help, much appreciated