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.

How to set default value of variable in catalog item.

Priya75
Tera Contributor

HI All,

I have a catalog item with variable( sub-state) and when we submit the catalog a new record is created on the hardware table. I have created a onload catalog catalog client script, which sets the value of sub-state to available. when i open this record in  the hardware table, the new choice is getting created rather than the old value being used. i have used the sys_is of the record in catalog script. .

11 REPLIES 11

No the default value isn't working, as substate is depended on state and there is a reference qualifier on the sub-state variable.The catalog script  is this 

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setValue("substate","available_state");


}

Rakhesh
Kilo Guru

In Hardware table, do you have sub state field? if yes what are the choices?

Priya75
Tera Contributor

Yes the sub- state is a field on hardware table , which is getting populated from the catalog item variable .There are different choices depending upon the state.

So in sub- state dictionary have u set the dependent on field to state in hardware table??

have you given dependent values to sub-state choices ?

And what is the new choice is getting created rather than the old value ? can u explain little bit

 

 

Priya75
Tera Contributor

yes on hardware table also the sub-state is depended on state.

yes the value is given .

the new choice is in blue colour same as that is given "Available" . when i try to update this record the value is set to the right choice and the new created choice desappers.