- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2016 09:12 AM
I have created a UI Page in which I am trying to access the logged in user's sys_id. The UI Page is presented as a widget on homepage.
When accessing the page through "UI Page" in the meny, I can access the user's sys_id. But when accessing the UI Page from the homepage it is not available.
Here is the significant part of the UI Page:
Script:
$j(function() {
$j("#check_in_area").ready(function() {
alert(g_user.userID);
});
});
I have included following row in the HTML field:
<g2:client_script type="user" />
Widget:
function sections() {
return {
"Check in counter" : { "name" : "Check In and Out Front and Back Office" }
};
}
function render() {
var name = renderer.getPreferences().get("name")
var gf = new GlideForm(renderer.getGC(), name, 0);
gf.setDirect(true);
gf.setRenderProperties(renderer.getRenderProperties());
return gf.getRenderedPage();
}
function getEditLink() {
return "";
}
What is the problem? How come it works when accessing the page from UI Page in the menu but no from the UI Page as a widget on a homepage?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:08 AM
By adding this code to the HTML part, the userID (user's sys_id) is available on the client side when embedding the UI Page in a widget:
<script>
var g_userID="$[gs.getUser().getID()]";
</script>
Then you can access the user's sys_id in the client script just using the variable "g_userID".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2016 10:19 AM
Can you post your Widget script here.
-Hardik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2016 11:05 PM
Thanks for getting back at me. Please find the code included below.
function sections() {
return {
"Check in counter" : { "name" : "Check In and Out Front and Back Office" }
};
}
function render() {
var name = renderer.getPreferences().get("name")
var gf = new GlideForm(renderer.getGC(), name, 0);
gf.setDirect(true);
gf.setRenderProperties(renderer.getRenderProperties());
return gf.getRenderedPage();
}
function getEditLink() {
return "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:08 AM
By adding this code to the HTML part, the userID (user's sys_id) is available on the client side when embedding the UI Page in a widget:
<script>
var g_userID="$[gs.getUser().getID()]";
</script>
Then you can access the user's sys_id in the client script just using the variable "g_userID".