- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 11:37 PM
Hello team, how can I define value in client script in Service Portal and how to show it in HTML?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2025 09:26 PM
Please mark my response correct and helpful, if it helps you.
Please reply if any issue happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2025 09:26 PM
Please mark my response correct and helpful, if it helps you.
Please reply if any issue happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2025 09:41 PM
Hello @YashikaG
Client scripts in Service Portal use AngularJS-style bindings to interact with widgets
Example :-
function($scope) {
// Define a value in the client script
$scope.data.myValue = "Hello, Service Portal!";
}
You can use AngularJS bindings ({{ }}
) in the HTML template of the widget to display the value defined in the client script.
<div>
<h2>{{data.myValue}}</h2>
</div>
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2025 11:30 PM
Hi @YashikaG
what was wrong in my answer? could you please clarify ?
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2025 09:54 PM
Steps to Follow:
Define Value in Client Script
- Use $scope to define and set a value in your client script.
- Example:
function($scope) { $scope.message = "Hello, Service Portal!"; }
Show Value in HTML
- Use AngularJS expressions ( {{ }} ) to display the value in the HTML template.
- Example:
<div> {{message}} </div>
Full Example:
Client Script
function($scope) { // Set the value $scope.greeting = "Welcome to the Service Portal!"; }
HTML Template
<div> <h2>{{greeting}}</h2> </div>