Unable to auto populate User details from OnLoad Catalog Client Script

Yerasu Mallikar
Kilo Contributor

Hi All,

Can anyone help me to auto populate User details on Catalog Form using OnLoad Catalog Client Script.

As written Script include also.

@Ankur Bawiskar 

Catalog Form:

find_real_file.png

find_real_file.png

 

Script include:

find_real_file.png

find_real_file.png

 

Catalog Client Script:

 

find_real_file.png

find_real_file.png

find_real_file.png

Variable Values:

find_real_file.png

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,

I would suggest there is a easier and no code option available OOB which you can use to auto populate this.

Please find the steps below:

Navigate to your Catalog Item and there is a Related List named "Catalog Data Lookup Definition" as shown below:

find_real_file.png

2) Click on New button as shown above:

find_real_file.png

3) Click on new button in Related List "Catalog Matcher Variable Definitions" as shown below:

find_real_file.png

Now Configure this as shown below:

find_real_file.png

Now click on New on the other Related List where you can set the values you want as shown below:

Catalog Setter Variable Definitions:

find_real_file.png

Now just set the variable values which you want:

Here I have set Email. Similarly you can set other variable from User Table

find_real_file.png

Result:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

19 REPLIES 19

Gabor10
Mega Guru

Hello there!

 

There are more than a couple things wrong here, but first of all I would suggest that you focus on your Script Include GET_requester_info.

You are setting the same value "loc.name" 4 times. This can not be right.

Please make sure you are referencing the correct fields from the sys_user table and also keep in mind that if you have "string" variables on your catalog item, you will need the display value of the field, if you have a reference variable on your catalog item, you will need the sys_id of the corresponding record.

In your client scripts, it's always useful to use console.log() to see what kind of response you are getting.

 

 

Additionally, in your client script "Employee info" you are setting the wrong value to the sysparm_name parameter. I am confident it should be 'getUserInfo' and not 'requestor'

And I am not sure why you have 2 seperate script includes and 2 seperate client scripts that basically query the same record twice. You should easily be able to merge and have only 1 script include and 1 client script that takes care of the employee information.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Have you considered a no code approach?

- 2021-02-11 Catalog Data Lookup Definition on any table, eliminating Catalog Client Scripting

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark - I think the issue with using Catalog Data Lookup is that they only work on Change not on Load.

 

Thanks