- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:26 AM
hello @BhupeshK
You can use below code. it will work for you.
Server :
data.value = "Server Side Defined value";// Define a value using data object
HTML:
//Show it using ng-bind and {{}}
<p>Valuse Passed from Server Side to HTML: {{c.data.value}}</p>
<p ng-bind="c.data.value"></p>
Please mark my answer correct and helpful if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:59 AM
Hello @BhupeshK
To display a server-side value in an HTML template in Service Portal, you can use the following approach:
Server-Side Script (in the Widget's Server Script):
(function() {
// Example: Fetching a user record
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
data.userName = gr.getValue('name'); // Passing user name
data.userEmail = gr.getValue('email'); // Passing user email
})();
HTML Template (in the Widget's HTML Section):
<div>
<p><strong>User Name:</strong> {{data.userName}}</p>
<p><strong>User Email:</strong> {{data.userEmail}}</p>
</div>
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:21 AM
how can I show a server side defined value in HTML in portal?.Please help with script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:26 AM
hello @BhupeshK
You can use below code. it will work for you.
Server :
data.value = "Server Side Defined value";// Define a value using data object
HTML:
//Show it using ng-bind and {{}}
<p>Valuse Passed from Server Side to HTML: {{c.data.value}}</p>
<p ng-bind="c.data.value"></p>
Please mark my answer correct and helpful if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:30 AM
is this for widget?
If yes then this is how you can pass info from server side to HTML in widget
Server:
(function() {
data.name = gs.getUser().getDisplayName();
data.department = gs.getUser().getRecord().getDisplayValue("department");
})();
HTML:
<h4>Name: {{data.name}}</h4>
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:30 AM
Hi @BhupeshK
Server side :
data.value = "23";
HTML side:
<p>{{data.value}}</p>
Thanks
dgarad