suvro
Mega Sage
Mega Sage

While replying to queries from users, I came across a common question which many user ask specially when they have started their ServiceNow journey and Service Catalog is the first thing they get to work on, that is 

 

How to fetch other details of the user like department, mobile number, etc of a user when it is selected as requested_for. So below is the step by step guide to achieve the same/similar query

 

 

1. Create an OnChange  client script on change of variable requested_for

  • Initialize GlideAjax with the name of the script include that you want to use.
  • When creating the script include, you must set the name field to be exactly the same as the class name.
  • When creating the script include, you must select the Client callable check box.
  • Specify the parameter sysparm_nameGlideAjax uses sysparm_name to find which function to use.
  • Any extra parameters may be passed in, all of which must begin with sysparm_. Avoid using predefined parameter names:
    • sysparm_name
    • sysparm_function
    • sysparm_value
    • sysparm_type
  • Code is then executed with the getXML() or getXMLWait() functions

 

Below is the example client script

find_real_file.png

Below is the example script include

find_real_file.png

Below is the output

find_real_file.png

 

You can also send an array of results using this method. Please bookmark and subscribe this article if you find it useful. As it will help you in many of your requirements

 

To learn more about GlideAjax follow below link

https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

 

For a zero code approach you can always use the article on Catalog Data Lookup Definition

Comments
Mark Roethof
Tera Patron
Tera Patron

Hi there,

Have you also considered using Catalog Data Lookup Definition instead? Zero code.

Kind regards,
Mark

Allen Andreas
Administrator
Administrator
Version history
Last update:
โ€Ž05-30-2022 12:28 AM
Updated by: