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.

If the service offering is set to XXX the following XXX and YYY task templates should be deactivated

Community Alums
Not applicable

Hi All,

I have a requirement in service catalog like If the service offering is set to 'XXX' the following 'AssetCtask:Deliver/Install IT equipment'  task template should be deactivated. How it can be achieved?

Can we acheive it using OnSubmit Client Script?

Thankyou.

 

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I wrote a code on the Template Spawn hierarchy to make it work. It worked. Thankyou.

View solution in original post

11 REPLIES 11

Dan H
Tera Guru

Hi Karthik,

Because you need to access server code and i'm assuming the task template information is not visible to the end user I would consider using a business rule to do this.

Trigger is Service Offering == 'valuehere' and catalog item is == 'x'

Then do a GlideRecord call to find the task template and set active = false.

You could do this with a Client Script and a GlideAjax call to the server database too.

 

Please mark my answer as helpful/correct based on impact

Community Alums
Not applicable

Thankyou i will try below code

Before Buisness Rule:

var gr = new GlideRecord('sys_template');

gr.addQuery('sys_id','865bc849540207073309506393994944t975879949');

gr.query();

if(gr.next()){

current.active='false';

}

Community Alums
Not applicable

Before Buisness Rule:

var gr = new GlideRecord('sys_template');

gr.addQuery('sys_id','865bc849540207073309506393994944t975879949');

gr.query();

if(gr.next()){

current.active='false';

}

I tried the above code and still the Task template is in active status

find_real_file.png

 

Hi,

Remove the '' around false,

You have: current.active='false';

Try: gr.active = false;

gr.update();

You need to use the gr object that you initialized to get the record