Script/UI Policy to set a Variable Set Variable value depending on Variable Value

danielbartholom
Mega Expert

Hi,

Can someone kindly help me to achieve the following:

I have a Cat Item and there is a variable Model Category (A Reference looking at cmdb_model_category)

Also within the Cat Item I have a variable set which includes a Variable (Referencing change_request > Category field)

What I am looking for is if you select in the Model Category field Windows Server then the Category field within the Variable set will set to Server

So I have tried the following:

Catalog UI Policy

When to Run = Model Category CONTAINS Server

Script (Execute if true)

g_form.setValue('category', Server);

Also tried

g_form.setValue('category', 'Server');

This does not work. Is it because the script cannot recognise category within the variable set?

Any assistance would most appreciated.

Regards

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Daniel,

Why not do this scripting in client script instead of ui policy.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ct111
Tera Sage

Hi DAniel ,

 

PLease send the entire script . 

So,

 

UI Policy is created on the Cat Item:

 

When to Run = Model Category CONTAINS Server

Script

Execute if true:

 

function onCondition() {
g_form.setValue('category', Server);
}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Daniel,

Why not do this scripting in client script instead of ui policy.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@danielbartholomew 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader