The CreatorCon Call for Content is officially open! Get started here.

How can I conditionally set the default value of one of the fields based on the another column value in the form?

Rebecca L
Tera Expert

We have a form with custom fields.  How can I conditionally set the default value of one of the fields based on the another column value in the form?  Although maybe not best practice, I am trying to simply use the following script in Configure Dictionary > Advance View > Default Value.  The value would be hard-coded to a specific user name if u_enhancement_type is equal to 'ABC', the default value when selected from ABC catalog.

javascript:if (current.u_enhancement_type("ABC")) current.u_business_system_analyst_1 = 'FirstName LastName';

 

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

here you go..

 

javascript:if (current.u_enhancement_type=="ABC")

current.u_business_system_analyst_1 = 'FirstName LastName';

View solution in original post

3 REPLIES 3

Abhishek77
ServiceNow Employee
ServiceNow Employee

If the field u_business_system_analyst_1 is not a reference you can use the above code you mentioned.

If that field is a reference field you need to use this gs.getUser().getUserByID('ron.kettering').getID()

 

Mark the answer as Correct/Helpful based on its impact.

Would the glide script be used after the equal (=) sign?

Such as, 

javascript:if (current.u_enhancement_type("ABC")) current.u_business_system_analyst_1 = gs.getUser().getUserByID('ron.kettering').getID()

Abhinay Erra
Giga Sage

here you go..

 

javascript:if (current.u_enhancement_type=="ABC")

current.u_business_system_analyst_1 = 'FirstName LastName';