Service Catalog - Variable Set Client Script

amacqueen
Mega Guru

Firstly I am no coder, so if you are able to help please ELI5.

On a Catalog item I have two variable in a variable set called Service Now User Details they are 1) requested_for and is reference on the sys_user table  and has a default value of requested_for -> javascript: gs.getUserID(); 2) The second variable is called email_address again a reference on the sys_user table with a default value of javascript:gs.getUser().getEmail();. I need to do something similar for country code from the users record.

My desired result when I 'Try' the item is that I get an empty field for Requested For and once I look up a user and select them the email address will autopopulate. with their email address and country code

I've read loads of community posts and mostly they refer to client scripts and occasionally to glide ajax but can't get my head around it!

Also if I client script is required is that added to the variable set Catalog Client Script section or to the item Catalog Client Script section.

Hope this makes sense but any questions plase ask

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Maybe this helps:
- 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

View solution in original post

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Maybe this helps:
- 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

Thanks I'll take a look

Great @Mark Roethof it worked for me, at least once I'd corrected my stupid mistake of trying to use it to populate a variable that was itself a Reference variable ;o)  

Prasad Pagar
Mega Sage

Hi @amacqueen 

There are 2 ways of looking at it.

1. If you auto-populate Requested for then you can get other fields populated to

2. If you want to get them populated based on Requested for value or on change of requested for then you can write Client Script(Onchange) in Variable set itself.

3. You can also have catalog definition lookup where you dont need client script at all.

Hope this helps

Thank you
Prasad