Populating Reference Field Dropdown Dynamically Using GlideAjax on onChange Event

Deepika Mishra
Mega Guru

Hi All,

I have a reference field: Case Type which is showing dropdown values using a reference qualifier.
Reference Qualifier: 
javascript: new global.ScriptIncludeName().functioncall(current.assignment_group.getDisplayValue());

Note: this is not a client callable script include.
This is working absolutely fine when form is loading.

I have a on change client script where the field: Case Type should populate on changing the assignment group.
As the previous one was not client callable, I made one Client callable script include and returning the choices and adding them as an option. However it doesn't seems to be working. 

How can I make this work ?

1 ACCEPTED SOLUTION

Deepika Mishra
Mega Guru

I added dependent field as assignment_group and it started working. No code was required.

View solution in original post

7 REPLIES 7

Deepak Negi
Mega Sage
Mega Sage

How are you populating it?

ideally the reference qualifier should automatically work based on the config you have shown. 

How are you returning the list for Case type on change of assignment group?

Deepika Mishra
Mega Guru

Reference Qualifier:
javascript: new global.ScriptIncludeName().functioncall(current.assignment_group.getDisplayValue());

 

Problem:

Now, I need to dynamically populate the Case Type dropdown based on the Assignment Group when the field is changed. To achieve this, I created a Client Callable Script Include, but it is not working as expected.

The steps I followed:

  1. Created a Client Callable Script Include that returns the choices for Case Type based on the selected Assignment Group.
  2. Made an onChange Client Script that calls the Script Include via GlideAjax when the Assignment Group field is changed.

Observations:

  • The onChange client script is correctly calling the Script Include via GlideAjax, and the sys_id and value (display value) are being returned in the response.
  • The Case Type dropdown is not populating when the Assignment Group is changed.

What I'm Looking For:

  • Insights on why the dropdown is not populating after calling the Script Include via GlideAjax.
  • Suggestions on how to dynamically populate the reference field after the Assignment Group is changed.



As @Deepak Negi rightly said , you need to return sys_ids as field is a reference field.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Deepak Negi
Mega Sage
Mega Sage

as the case type is a reference field you need to populate the sysid.

 

g_form.addOption only work for choice fields.

 

try below

g_form.setValue("<fieldname>",caseType.sys_id);