retrieving value from comments field in sysapproval table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-28-2018 05:48 AM
when the approver approves ,he enters a unique code in the comment and i need to retrieve that value and update in a new field in ritm table.
its journal input type and it shows my name ,time stamp and then the value appended.
i tried both -1 and 1.
how do i get only the value input by the approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-28-2018 05:54 AM
That should work. Here is an example I tested it with. The sysID is from an approval record:
var sys = '00e9c07adba52200a6a2b31be0b8f5ae';
var current = new GlideRecord('sysapproval_approver');
current.get(sys);
gs.debug(current.comments.getJournalEntry(1));
//Gƶran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-28-2018 06:00 AM
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
if(gr.next())
{
current.u_application_ci_name = gr.comments.getJournalEntry(-1);
gs.log('comments approval :'+gr.comments.getJournalEntry(-1));
gs.log('comments approval :'+gr.comments.getJournalEntry(1));
}
// Add your code here
})(current, previous);
I entered "test1" in comments field
logs
------------
comments approval :2018-10-28 18:10:03 - Chinmayee Mishra (Comments)test1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-28-2018 06:47 AM
Ahh, sorry, missed that you just wanted the value. Then we need to trim down the string abit. this should work:
var sys = '00e9c07adba52200a6a2b31be0b8f5ae';
var current = new GlideRecord('sysapproval_approver');
current.get(sys);
var com = current.comments.getJournalEntry(1);
gs.debug("Value is " + com.substring(com.indexOf('(Comments)')+10).trim());//Finds where (Comments) is and add 10 characters since (Comments) is 10 characters. Then take the rest of the string
//Gƶran