- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 04:01 AM
I'm looking for a way to query the open record on the ticket page of service portal, and add an html table of the receivers to a widget. I've tried doing this on the ticket fields widget, and the html widget with no success.
Basically, I have tried querying the current record and storing the receivers in data.rcvrs, then calling that in the body html template but I get nothing. Anyone able to advise?
var currentRequestID = $sp.getParameter("sys_id"); | |
var requestGR = new GlideRecord('TABLE'); | |
requestGR.addQuery('sys_id', currentRequestID); | |
requestGR.query(); |
data.rcvrs = requestGR.receivers+''; |
Then calling {{data.rcvrs}}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 06:10 AM
first..put your styles in css part of the widget.
in HTML part..do something like this. im assuming your data structure is like this.
c.data.rcvrs = [{"name":"Ross","u_department_name":"dinosouers","manager_name":"Mr History"},{"name":"Joey","u_department_name":"food","manager_name":"Mr Pizza"}]
so basically you need array of objects.. objects would contain 3 properties.. name, u_department_name,manager_name(do this inside server script while loop where you are fetching data)
HTML code.
<table>
<tr>
<th>Name</th>
<th>Dept.</th>
<th>Manager</th>
</tr>
<tr ng-repeat="user in c.data.rcvrs">
<td>user.name</td>
<td>user.u_department_name</td>
<td>user.manager_name</td>
</tr>
</table>
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 05:10 AM
after line 9..you need to do requestGR.next()...
or put then on while loop n iterate over result if more then one is retured.
also on html call like this
{{c.data.rcvrs}}
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 05:48 AM
Perfect. I have that working now. Thank you!. Now to the table portion. In notification email scripts, I use the following. I am needing to get this into the the widget I am using to populate data.rcvrs so that I have a clean table layout. I am doing this so I can cleanly display the user and some other information about them such as manager and department. Any thoughts on converting?
template.print('<style>');
template.print('table {border-collapse: collapse;border: 2px solid #ddd;text-align: left;}');
template.print('th, td {padding: 3px;border: 1px solid #ddd}');
template.print('tr:hover{background-color:#f5f5f5}');
template.print('</style>');
template.print('<table>');
template.print('<tr>');
template.print('<th>Name</th>');
template.print('<th>Dept.</th>');
template.print('<th>Manager</th>');
template.print('</tr>');
//loop through the array, add rows to receiver table
while (grusers.next()) {
template.print("<tr>");
template.print("<td>" + grusers.name + "</td>");
template.print("<td>" + grusers.u_department_name + "</td>");
template.print("<td>" + grusers.manager.name + "</td>");
template.print("</tr>");
}
//close the table
template.print('</table>');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 06:10 AM
first..put your styles in css part of the widget.
in HTML part..do something like this. im assuming your data structure is like this.
c.data.rcvrs = [{"name":"Ross","u_department_name":"dinosouers","manager_name":"Mr History"},{"name":"Joey","u_department_name":"food","manager_name":"Mr Pizza"}]
so basically you need array of objects.. objects would contain 3 properties.. name, u_department_name,manager_name(do this inside server script while loop where you are fetching data)
HTML code.
<table>
<tr>
<th>Name</th>
<th>Dept.</th>
<th>Manager</th>
</tr>
<tr ng-repeat="user in c.data.rcvrs">
<td>user.name</td>
<td>user.u_department_name</td>
<td>user.manager_name</td>
</tr>
</table>
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 08:57 AM
So I need 3 arrays? I'm struggling a lot on this. If I push the receiver list (the receiver names only), it comes through in a comma separated list such as User1, User2. I can't seem to parse that correctly.
However, if I manually set data.rcvrs in the server script, I can call it just fine and I get 2 rows:
data.rcvrs = ['User1', 'User2'];
I'm just not sure how to push all of the needed data into an array and then separate it for the table.