Auto populate reference variable based on another reference variable on a catalog item form. I have reference variable Application referring to 'Name' field on Applications (cmdb_ci_appl) table and another list field called 'Roles' in it. On catalog

jyotsna1
Giga Contributor

Auto populate reference variable based on another reference variable on a catalog item form. I have reference variable Application referring to 'Name' field on Applications (cmdb_ci_appl) table and there is a list field called 'Roles' on same table, which has multiple roles associated to each application (these roles are maintained in a separate custom table). On catalog Item I want to populate roles from this list field values in a variable based on the application selected on catalog form. 

Hope someone helps me get this! Thank you

16 REPLIES 16

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Seems duplicate question

I already replied to something like this earlier

https://community.servicenow.com/community?id=community_question&sys_id=39544f5ddbdf50d07d3e02d5ca96...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thanks for your response!

Previous solution did not work for me. I tried something which is working on ITIL view(when I click Try it on catalog form it works) but not working on portal.

1 Reference Field - Application (cmdb_ci_appl)

2 List Collector Field - Security roles (custom table)

On Change Client Script when application changes

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var gr= new GlideRecord('cmdb_ci_appl');
gr.addQuery('sys_id', newValue);
gr.query();
if(gr.next())
{
g_form.setValue('security_roles',gr.u_security_roles);
}
}

Its not working in portal view, Is it something with Orlando or please let me know if you could point in correct direction here.

Thanks in advance!

Hi,

If your previous question answered then please close it by marking appropriate response as correct.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

GlideRecord is not supported in client script in portal; hence it is not working

please use GlideAjax and script include

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader