Dynamically Populate a Field Based-on the Value(s) of Another Field

appstorm
Tera Contributor

I have been working on several on-change client scripts to make this work, but have so far been unsuccessful.  The task to make two fields that share the same table populate with their respective values, based-on the value of another field from the same table.

find_real_file.png

find_real_file.png

Below, is my script include.

find_real_file.png

 

How do I go about writing an on-change CS to make this work?

Thank you!

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

This is what I have defined in my PDI:

Hfind_real_file.pngHave added the fields to the Change Request form:

find_real_file.png

After flushing the cache, when I change System, Analyst and Owner automatically update.

View solution in original post

38 REPLIES 38

Yep, my code matches your example, with "System" being the onChange field name.  Do Owner and Analyst need to be string fields, instead of reference fields?  I have to add this is on the Change form on the platform view, not the portal.  This is why I thought a script include was necessary.

Hi @appstorm 

No you dont need Script include even for Platform view.

Reference fields are also fine.

I feel the issue is you are not giving correct field names.

Can you please show me field names for your fields?

find_real_file.png

Right click on field it will show you logical name. For e.g Configuration item field logical name is 'cmdb_ci'. What is it for your fields in 'Change Request System Owners' and also on below form? Use them in script it should work.

find_real_file.png

Thank you
Prasad

Hi Prasad! 

I am looking into your solution I think I have identified the issue. 

In my custom table, System Owner is actually Product Owner, with a field name of "owner".  On the Change Request table, this field is named "u_system_owner".  Don't these two fields have to share a common name and if so, adding System Owner uses a 'u' prefix.

Otherwise, all other names are the same.

-O-
Kilo Patron
Kilo Patron

You can also accomplish this by using (System Policy -> Rules -> ) Data Lookup Definitions. No code needed. Also custom table will be "free".

appstorm
Tera Contributor

Tried and still nothing (see below).

find_real_file.png