i cant get ng-repeat to work properly in my portal widget, can anyone help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 12:41 PM
I am pulling the list of journal entries for a widget i am building but im unable to get them to display in my widget, can anyone help?
i know my pull is working as i did an info message and was able to see all 4 fields:
gs.addInfoMessage("Value: "+wn.getValue('value')+" Created: "+wn.getValue('sys_created_on')+" Created By:"+wn.getValue('sys_created_by')+" Type: "+wn.getDisplayValue('element'));
but the HTML shows NOTHING for the block.
HTML snippet:
<table>
<tr><td>Activity Log:</td></tr>
<tr ng-repeat="entry in data.journal">
<td>{{entry.type}}</td>
<td>{{entry.notes}}</td>
<td>{{entry.createdby}}</td>
<td>{{entry.created}}</td>
</tr>
</table>
Server Code Snippet:
data.journal = [];
data.sysid = $sp.getParameter('sys_id');
var wn = new GlideRecord('sys_journal_field');
wn.get('element_id', data.sysid);
while(wn.next())
{
var entry = {};
entry.notes = wn.getValue('value');
entry.created = wn.getValue('sys_created_on');
entry.type = wn.getValue('element');
entry.createdby = wn.getValue('sys_created_by');
data.journal.push(entry);
}
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 12:56 PM
What do you get if you print data.journal directly in the html?
{{data.journal}}
<table>
<tr><td>Activity Log:</td></tr>
<tr ng-repeat="entry in data.journal">
<td>{{entry.type}}</td>
<td>{{entry.notes}}</td>
<td>{{entry.createdby}}</td>
<td>{{entry.created}}</td>
</tr>
</table>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 01:26 PM
i get: [{"notes":"test","createdby":"NAME","created":"2022-02-01 18:21:00","type":"work_notes"}]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 01:45 PM
I think i had a reserved name or something, i adjusted from journal to ticketjournal, and now it seems to be working.