Service Portal - Create html table of receivers on a widget?

robhaas
Tera Contributor

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}}

1 ACCEPTED SOLUTION

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)


View solution in original post

7 REPLIES 7

robhaas
Tera Contributor

After some more reading and learning, I have gotten this to work. Thank you very much for your help!


cool..sorry if i confused you with that 3 array example


Creating my own widget for fun and was stuck on this, until I found your comment. Thanks 🙂