pass variables from Server Script to html template in Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 05:08 AM
Hi ,
I am trying to build widget in service portal . I created a variable with Type as Custom in Record Producer. I am trying to push server side script data to html template. Its blank in html template. attached screenshot in question .Please check and let me know where i am doing wrong
this is the Widget which is created:
html template ::
<div>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Code</th>
</tr>
</thead>
<tbody>
<td> {{data.Name}}</td>
<td> {{data.Code }}</td>
</tbody>
</table>
</div>
Client Controller :
var c = this;
c.data.multiple_po = $scope.page.g_form.getValue('po');
c.updateNote = function() {
c.server.get({
multiple_po: c.data.multiple_po
}).then(function(r) {});
};
c.updateNote();
Server Side SCript :
if (input) {
var vendorName, companyCode;
var poTable = new GlideRecord('purchase_order');
poTable.addEncodedQuery('sys_idIN' + input.po);
poTable.setLimit(1);
poTable.query();
if (poTable.next()) {
Name = poTable.getDisplayValue('id');
Code = poTable.getDisplayValue('code');
}
data.Name = Name;
data.Code = Code;
}
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 05:13 AM
Hi,
Update below as
<td> {{c.data.Name}}</td>
<td> {{c.data.Code }}</td>
Regards,
Muhammad
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2023 11:19 AM
Como eu posso fazer o contrário?
Pegar por exemplo, uma data que o usuário escolheu no Html e trabalhar com esse valor no Server script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 07:13 AM
Can you try this in server script:
if (input) {
var vendorName, companyCode;
var poTable = new GlideRecord('purchase_order');
poTable.addEncodedQuery('sys_idIN' + input.multiple_po);
poTable.setLimit(1);
poTable.query();
if (poTable.next()) {
Name = poTable.getDisplayValue('id');
Code = poTable.getDisplayValue('code');
}
data.Name = Name;
data.Code = Code;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 06:50 AM
Its not working .. I tried