- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 08:07 PM
I want get the current user name and user id ,display in the preview
plase help me
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 03:14 PM
Hi zhian,
If you look at the screenshot that I posted earlier the fields that are references have two correlating properties. One property displays the sys_id of the referenced record and the other one displays the display value of the record. It's indicated by the suffix of "_dv" at the end of the property name.
So to show the display value of the department it would be user.department_dv instead of user.department.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 10:17 PM
I succeeded, thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 10:29 PM
Hi,
You can try below scripts:
HTML Template:
<div class="button-box">
<!-- your widget template -->
<p>User name : {{data.username}}</p>
<p>User ID : {{data.userid}} </p>
<p>User Email : {{data.mail}} </p>
</div>
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.username = gs.getUser().name;
data.userid = gs.getUser().getDisplayName();
data.mail = gs.getUser().email;
})();
Result:
You can add background colors and other styling as per requirement.
Hope it helps!!
Please Mark ✅ Correct/Helpful, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 10:42 PM
This was helpful.
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 11:17 PM
Hi,
Good to hear!
Please Mark ✅ Correct/Helpful, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 05:58 PM
thank you for your help