- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2016 11:02 AM
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,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2016 09:11 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2016 10:12 AM
Are you using this in a scoped application (extension)? What version of ServiceNow? I may have a workaround based on those two factors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2016 10:32 AM
This is not a scoped application and I am on Fuji.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2016 11:01 AM
Hi Chad,
Don't worry about the JSON warning. It's bogus. JSON as a constructor
As for the other two properties. Do me a favor, put an alert line right after the var answer = to see what is being returned in your stringified object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2016 11:26 AM
ok, added the alert.
Where will I find the output?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2016 11:34 AM
It should jump up in your face as soon as you change the user. If you're not seeing it, then something else is wrong on the server side that is causing it to abort. Welcome to the world of debugging client/server apps. 🙂
If you want to find out how far the server is getting, drop in some gs.log() statements and you can see them under System Logs> Script Log Statements.
I had to do this a bit last night to get the code running.