Setting variable in order guide

codedude
Mega Expert

I have an order guide that has a check box on it called application. If that is checked, when the user clicks the button Choose Options it then pulls up the application request in a tab inside the order guide.

My problem is I want to set the values of some of the variables on the application request for the user. For instance (When the user selects application and clicks the button Choose Options, when they go to the application request tab, I want to have check box Mirosoft_Word already checked for them.

I have tried this on an onChange script on the order guide, but it is not working...

    g_form.setValue('microsoft_wordt', 'true');

But this does not work...

NOTE: The variables for the application request are in a variable set

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If you always want it checked you can make its default value true, but I'm assuming here that you only want the box to be true if it's included in the order guide. In that case you would have to include something in the item that indicates whether the item was called from an order guide or by itself. I like to add a variable set with either a checkbox or multiple choice variable to the items included in the order guide and then hide that variable by default with a client script. You would cascade the value from the order guide so it would be true if called from the order guide and false if not. Then you can key an onload client script off of that variable and set the value on your checkbox.


View solution in original post

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If you always want it checked you can make its default value true, but I'm assuming here that you only want the box to be true if it's included in the order guide. In that case you would have to include something in the item that indicates whether the item was called from an order guide or by itself. I like to add a variable set with either a checkbox or multiple choice variable to the items included in the order guide and then hide that variable by default with a client script. You would cascade the value from the order guide so it would be true if called from the order guide and false if not. Then you can key an onload client script off of that variable and set the value on your checkbox.


HV1
Mega Guru

To cascade variables. it requires the same variable name on both the order guide and the ordered items. Below link for reference.


Service Catalog Order Guides - ServiceNow Wiki



So create a new variable in your catalog item with the same name as the one on order guide. Then create an onChange client script on your catalog item:


g_form.setValue('microsoft_wordt', 'true');  



(Is the name of the field above "microsoft_wordt" or "microsoft_word" ?)



Regards,


Hardik Vora


That was a typo on my end 😕