ServiceNow Reference Qualifier | Call Script include in Servicenow Advance Reference Qualifier

Опубликовано: 28 Сентябрь 2024
на канале: TechnoMonk
3,513
64

Hi Folks ,

In this video we will focus on ServiceNow Reference Qualifier . We will see how we can Call Script include in Servicenow Advance Reference Qualifier.
Lets first understand what is reference qualifier in servicenow.
Use reference qualifiers to create filters that restrict the data that is returned for a reference field.

A reference field stores a link (reference) to a field on another table, making the records/fields in the referenced table available to the form containing the reference field.

For example, the Assigned to field on the Incident table is a reference to the User [sys_user] table. By default, all values for the field that is being referenced appear in the reference lookup and can be directly accessed through the reference field (type ahead). Expanding on the prior example, if a reference qualifier is not defined, all users in the User table appear in the reference lookup. Including those users that are inactive. Sometimes, this might be the desired functionality. In other cases however, only a subset of the available values may be desired. In this case, create a reference qualifier to filter the available data so that only the desired values are returned and made available to the form. Such as only the active users or users that have a specific role. Reference qualifiers are robust and can consist of simple AND/OR conditions, inline JaveScript, or complex script include.
Advanced reference qualifier
Advanced reference qualifiers enable you to define an inline encrypted query string or JavaScript (actual code or the name of an existing script include or business rule) filter directly in the Reference qual field of the reference qualifier. Similar to the other reference qualifier types, when the form loads, the filter is executed, and only the records that match the filter appear in the reference field. Use this type of reference qualifier for implementations that only require a simple, unique filter, that cannot be handled by a simple reference qualifier, and is not used across multiple reference fields.
Note: As a good practice, make JavaScript calls to functions in a script include instead of a global business rule.
An example of an encoded query string is vendor=true, which returns all companies that are designated as vendors. Entering this string is the same as using the condition builder as shown in the example for the simple reference qualifier. For additional information on valid encoded query string syntax and examples, see Encoded query strings.
An example of a JavaScript call is javascript:new myScriptInclude().my_refqual(). This code calls the function my_refqual() in the script include myScriptInclude(). The function must return a query string that can filter the options available on a reference field.
Note: You can also use encoded JavaScript filters such as javascript:'u_active=true^' + "u_hr_service="+current.hr_service in reference qualifiers.

Please like follow suscribe to my channel Technomonk and press the bell icon to get the latest update on my new videos.
Till then stay happy and safe .
Have a nice day .

Regards,
Amit Gujarathi