Reference Qualifier based on Form View

Thenmozhi
Tera Contributor

Hi,

We have a requirement to apply reference qualifier for a reference field based on for form view. We have 2 views for location table say A & B. The reference qualifier specified on the Dictionary entry should be applicable only for view A and not on B.

Tried using 'gs.action.getGlideURI().getMap().get('sysparm_view')' to check the view. But this is always returning sys_ref_list which is the view of reference popup list.

Is there a way to get the view name of base form and apply reference qualifier accordingly.

Regards,

Thenmozhi

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

whenever you open reference field the URL always include the form view from where it got opened in this parameter -> sysparm_form_view

Below is the URL I got when I clicked the Assignment group field being on CHG Default view

https://instanceName.service-now.com/sys_user_group_list.do?sysparm_target=change_request.assignment_group&sysparm_target_value=&sysparm_reference_value=&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=assignment_group&sysparm_reference=sys_user_group&sysparm_view=sys_ref_list&sysparm_form_view=default&sysparm_additional_qual=&sysparm_domain_restore=false

When I changed to emergency view the URL included that as well

https://instanceName.service-now.com/sys_user_group_list.do?sysparm_target=change_request.assignment_group&sysparm_target_value=&sysparm_reference_value=&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=assignment_group&sysparm_reference=sys_user_group&sysparm_view=sys_ref_list&sysparm_form_view=emergencyChange&sysparm_additional_qual=&sysparm_domain_restore=false

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Naveen Velagapu
Mega Guru

hi Thenmozhi,

I don't think you will be able to access form view in the reference qualifier of a field. As you mentioned that there are two views. There might certain conditions in which those form views will be enforced to users as well. Try to append that as part of dynamic reference qualifier script you are trying to create. It would solve the issue.

 

Hit "helpful" if this is useful. 

Mark "correct " if this answers your question.

Thanks,

Naveen

Saurabh Gaikwad
Mega Expert

Hello Thenmozhi,

Try this method switchView(type,table,view).

https://servicenowguru.com/scripting/client-scripts-scripting/change-form-view-client-script/#:~:tex...

 

Regards,

Saurabh,

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

whenever you open reference field the URL always include the form view from where it got opened in this parameter -> sysparm_form_view

Below is the URL I got when I clicked the Assignment group field being on CHG Default view

https://instanceName.service-now.com/sys_user_group_list.do?sysparm_target=change_request.assignment_group&sysparm_target_value=&sysparm_reference_value=&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=assignment_group&sysparm_reference=sys_user_group&sysparm_view=sys_ref_list&sysparm_form_view=default&sysparm_additional_qual=&sysparm_domain_restore=false

When I changed to emergency view the URL included that as well

https://instanceName.service-now.com/sys_user_group_list.do?sysparm_target=change_request.assignment_group&sysparm_target_value=&sysparm_reference_value=&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=assignment_group&sysparm_reference=sys_user_group&sysparm_view=sys_ref_list&sysparm_form_view=emergencyChange&sysparm_additional_qual=&sysparm_domain_restore=false

Regards
Ankur

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

Hi Ankur,

I am not able to find sysparm_form_view= URL parameter in the reference popup.

https://instanceName.service-now.com/customer_account_list.do?sysparm_target=cmn_location.account&sysparm_target_value=<sys_id>&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=account&sysparm_reference=customer_account&sysparm_view=sys_ref_list&sysparm_additional_qual=&sysparm_client_record=session&sysparm_domain_restore=false.

 

I tried the same in Personal dev instance as well and I am not able to find it. Can you please provide more details on  sysparm_form_view.

Version: Paris.

Regards,

Thenmozhi