Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Client Script to Populate String Field w/ Reference Field Value

kevinthury
Tera Guru

We are looking for a way to populate the DisplayValue of a reference field into a string field on the form based on what is selected on another field.  Example...On Incident form, populate a custom Department field (u_department / string type) with the Departement of the Caller (caller-id / reference type).

In my personal instance, I have setup a GlideAjax call with a  Client Script / Script Include.  I am able to being over the value, but it is appearing as the sys_id.  To troubleshoot, I added another custom field of Department Reference (u_department_reference / Reference type on cmn_department table).  The desired value is displaying in the reference type field.

While the custom reference field type is a viable solution in this example, we have other requirements where we may like to have a reference field value populate a string field.  

Is there a way to do this?  Below are screenshots of the Client Script, Script Include, and the results on the Incident form.

find_real_file.png

 

find_real_file.png

find_real_file.png

 

 

 

 

1 ACCEPTED SOLUTION

Mohammed_Iqbal
Tera Guru

Hello,

make the below changes in your script include:

find_real_file.png

instead of user_detail.department write user_detail.department.name

 

 

HOPE THIS HELPS!!!! MARK CORRECT OR HELPFUL.

 

Regards,

Mohammed Iqbal

 find_real_file.png

www.dxsherpa.com

View solution in original post

4 REPLIES 4

Mohammed_Iqbal
Tera Guru

Hello,

make the below changes in your script include:

find_real_file.png

instead of user_detail.department write user_detail.department.name

 

 

HOPE THIS HELPS!!!! MARK CORRECT OR HELPFUL.

 

Regards,

Mohammed Iqbal

 find_real_file.png

www.dxsherpa.com

Thank you for the quick response, and extra thanks for the correct answer.  That simple change gave me exactly what I needed.

Brilliant!

Though, you found the answer, but to get the department value of the caller on incident form, you do not need a scripting. You can add the department field with dot walking.

Right click on the header -> Configure -> Form Layout and then select the caller

find_real_file.png

find_real_file.png

if you want department field as string a field then again expand the department field and use the name field,

find_real_file.png

 

welcome