how can I show a server side defined value in HTML in portal?

BhupeshK
Tera Contributor
 
2 ACCEPTED SOLUTIONS

amitshishod
Tera Guru

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.

View solution in original post

Juhi Poddar
Kilo Patron

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

View solution in original post

5 REPLIES 5

Juhi Poddar
Kilo Patron

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