- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2014 04:19 AM
Hi,
In a UI page, I need to check whether any user is currently logged in or not. I tried the below things to retrieve the details for checking,
1) I tried using g_form.userName in the client section of the UI Page. But i didn't get the user name.
2) I also tried in the Processing Script section by using the gs.getUserID() and tried to log the result. However here too i'm unable to see user name.
Can anyone please suggest, how should i try to retrieve current user details from a UI page?
Regards,
Kamal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2014 01:31 PM
For future reference if you need to actually get the username of the logged in user, one way to do it is use ${gs.getUser().name} or other properties like:
${gs.getUser().name} // same as username
${gs.getUser().firstName}
${gs.getUser().lastName}
${gs.getUser().fullName}
${gs.getUserID()}
Putting this in your example you gave earlier you would replace "g_user.userName" with "${gs.getUser().name}". Make sure you include the quotes.:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<head>
<script>
function myFunction()
{
alert('Hi');
var usr = "${gs.getUser().name}"; //remember quotes are still needed
alert('Bye ' + usr);
document.getElementById('user').innerHTML = usr;
}
</script>
</head>
<body onload="myFunction()">
<div id='user'></div>
</body>
</html>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2019 05:40 AM
Did you change the URL to reflect "sysparm_sys_id" too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2019 05:47 AM
I forgot to add you don't want to use:
'ui_page.do?'
Instead you should use the actual name of the UI page:
'my_ui_page_name.do?sysparm_sys_id=xxxxxxxxxxxxxxxxx'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2019 10:15 PM
ok.. and do let me know how to get incident form details in ui page.
When we are opening ui page by using window.open()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2019 10:11 PM
i did not get this please elaborate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2019 05:00 AM
When you create a UI page you can test it out by using "ui_page.do?sys_id=" and give the sys_id of the UI page record. In fact that's how it renders when you click on the 'Try It" button.
However, that's not what you want to use when actually using the page. You would call the UI page with the name given to it when it was created. The name that's populated in the "name" field of the UI page form.
For example if I created a UI page and on the form named it record_viewer, to render the UI page I would navigate to /record_viewer.do.
And if I had a parameter like sysparm_sys_id I wanted to pass I would do: /record_viewer.do?sysparm_sys_id=1234567890987654321y2t3re5wr3f9b
So in your example I would construct it like:
UI Action:
function printPreviewList(sysid) {
var features = "resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=yes,location=no";
var href = "the_name_of_my_ui_page_goes_here.do?sysparm_sys_id=f79b1548dbb323002fd3bd51399619b4";
var win = window.open(href, "Printer_friendly_format", features);
win.focus();
}
One important note: Do not give a UI page the same name as an existing table as it will override the OOB form. Unless this is what you want to do purposefully.