- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:42 PM
Hello!
How do I get other current user details (example location, department, phone) in a client script?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:57 PM
Hi,
Write below code in Display BR
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
g_scratchpad.location = gr.location.name;
g_scratchpad.department = gr.department.name;
g_scratchpad.number = gr.mobile_phone;
Write Below code in onLoad client script
g_form.addInfoMessage(g_scratchpad.location);
g_form.addInfoMessage(g_scratchpad.department);
g_form.addInfoMessage(g_scratchpad.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:57 PM
Hi,
Write below code in Display BR
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
g_scratchpad.location = gr.location.name;
g_scratchpad.department = gr.department.name;
g_scratchpad.number = gr.mobile_phone;
Write Below code in onLoad client script
g_form.addInfoMessage(g_scratchpad.location);
g_form.addInfoMessage(g_scratchpad.department);
g_form.addInfoMessage(g_scratchpad.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:30 AM
It works! Thank you so much.
I have one more problem. I want to populate these values to the additional comments field on load.
I tried the code below but it isn't working.
g_form.comments = g_scratchpad.location + " " + g_scratchpad.department + " " + g_scratchpad.number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:41 AM
Try as below,
g_form.setValue('comments', g_scratchpad.location + " " + g_scratchpad.department + " " + g_scratchpad.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:43 AM
Please mark my answer as correct and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:45 AM
Try like this also,
var detail = g_scratchpad.location + " " + g_scratchpad.department + " " + g_scratchpad.number;
g_form.setValue('comments',detail);