How to autopopulate catalog item variables using sys_user table

User163016
Tera Contributor

I have a request form that needs to auto populate 4 variables based on the user that opened the request.   The 4 fields are Project owner name, title, department and phone.   These are all fields that exist in the sys_user table.   I read through several discussions and found different variations on how to accomplish this, some of them with catalog client scripts but so far I have been unsuccessful with these suggestions.   Bhavesh Jain did suggested in a post to use javascript:gs.getUser().getFullName() in the default value field for name and that worked perfectly, but I'm unable to figure out how to get this to work for the other three fields.   Any help is appreciated.

Thanks,

1 ACCEPTED SOLUTION

Hi Chad,



I've attached a simple script include and client script that should do the job for you. You will   need to update the catalog client script to the right Catalog Item.



Check the field variable names, but I think you'll find it's all there.


View solution in original post

24 REPLIES 24

Thanks Chuck and Pradeep!   I'm new to scripting so I'll take a look at your respective links and see what I come up with.   I have a feeling I'll be responding with questions


The another way to pull this information out is using default value of variable with expression like,



Javascript: gs.getUser().getRecord().getValue('fieldNameGoesHere');


Hi Deepak,



That was the solution that Pradeep linked to. I have have concerns about performance with that one because it causes 1-2 server calls per variable! A GlideAjax would get it done with one.


Agree with you TechNow master


The other thing I just thought about with this approach is that it's static (a default value). If they change the user field, it's not updating the other fields.