- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:17 AM
I want to display first name of current user inside of widget.
inside of widget
HTML
<p>Hello, {{firstName}}</p>
SERVER SCRIPT
(function() {
var firstName = gs.getUser().getFirstName();
})();
What is wrong? I have tried many ways but have not been successful.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:21 AM
Try:
Do not declare data, as it is already declared as server side object.
server:
data.firstName = gs.getUser().getFirstName();
HTML:
<p>Hello, {{data.firstName}}</p>
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:21 AM
Try:
Do not declare data, as it is already declared as server side object.
server:
data.firstName = gs.getUser().getFirstName();
HTML:
<p>Hello, {{data.firstName}}</p>
Raghav
MVP 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:23 AM
HI,
IN Server code you should be always using data.XXXX and then in widget html you can access that data.xxxx in{{}}
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:28 AM
Hi Brook,
You should be able to get the user's first name from the scope, so write your client controller like this:
function($scope) {
var c = this;
c.welcome = $scope.user.first_name ;
}
And in HTML, in which field you want to get the data you can use this. {{c.welcome}}
So on this field you get the first name.
If this helps you then please mark correct or helpful.
Thanks
Swapnil