Querying document id type field in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2017 02:54 AM
Hi All,
I am trying to bring the comments of rejected KB on notification.
Following code is not give expected result. it adding all comments of other approval records.
var aprquery = new GlideRecord("sysapproval_approver");
aprquery.addQuery('sysapproval_approver', current.sys_id);
aprquery.addQuery("state", 'rejected');
aprquery.query();
while(aprquery.next()) {
template.print(aprquery.comments.getJournalEntry(1));
}
So I planned to build query on approval and sys_journal_field table with following code. When trying to query the document_id field using KB article sys id.
its not giving proper result.
var asy = current.sys_id;
var enQ= 'state=rejected^source_table=kb_knowledge';
var aprquery = new GlideRecord("sysapproval_approver");
aprquery.addEncodedQuery(enQ);
aprquery.addQuery('document_id',"220834be131f36008a3efc04e144b0b2"); //sys id of KB article 220834be131f36008a3efc04e144b0b2
aprquery.query();
var x= aprquery.getRowCount();
gs.log("VS###"+x);
gs.log("VS### Apr Sys "+aprquery.getUniqueValue());
gs.log("VS### Apr Sys "+aprquery.getSysId());
while(aprquery.next()) {
var b = new GlideRecord("sys_journal_field");
b.addQuery('name',"sysapproval_approver");
b.addQuery('element',"comments");
b.addQuery('element_id','aprquery.sys_id');
b.query();
while(b.next()){
template.print(b.value);
}
I tried by putting in my script no results found.
aprquery.addQuery('document_id',asy );
Please let me know what change i have to implement in my code.
Need to know any other ways to query the document id type fields.
Thanks
Vijay kumar .S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 03:11 AM
Don't GlideRecord journal entry table but use below to get comments. Use document_id to get target record.
aprquery.current.work_notes.getJournalEntry(-1);