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.

Conditional default value for catalog variable

pbo
Mega Expert

Is it possible to force default value of a catalog variable based on another variable oflike we do in ref qual ?

For example, we create a variable set with 2 field

  type : integer value

  test : string field

If type = 1   then default value for field Test is FirstName

if type = 2 then default value for field Test is LastName

We can like create a function testDefaultValue(type) and would like to use it to define default value for field test

For reference qualifier , syntax is javascript:testDefaultValue(current.variables.type) but this doesn't seem to work for default value (log says current.variables.type is not defined)

Thanks

2 REPLIES 2

dvp
Mega Sage

Why don't you write a onChange client script?


Abhinay Erra
Giga Sage

Here you go. Put this in the default value line



javascript: if(current.type==1) return 'FirstName'; else return 'Lastname';