How To get the comment which is provided while rejecting approval( not all comments )?

lp6
Tera Guru

I want to get the rejected comment only as the subject line but not all comments 

1 ACCEPTED SOLUTION

you need to remove that timestamp like this

var value = current.comments.getJournalEntry(1);

var str = value.split(' - ')[1];

var name = str.split(') ')[0] + ')';

var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;

gs.info(name);

var onlyComments = value.replace(dateRE, '');

template.print('Rejection comments' + onlyComments);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can pick the latest comments from approval record

you need to use email script for this

template.print(current.comments.getJournalEntry(1));

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, Thanks for help but I'm not getting exact comment please see below attachment. Rejected is the comment which is expecting but i'm getting timestamep and name.

find_real_file.png

you need to remove that timestamp like this

var value = current.comments.getJournalEntry(1);

var str = value.split(' - ')[1];

var name = str.split(') ')[0] + ')';

var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;

gs.info(name);

var onlyComments = value.replace(dateRE, '');

template.print('Rejection comments' + onlyComments);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi ankur Can u help me on below question https://community.servicenow.com/community?id=community_question&sys_id=219ebd31db758550bb4a474d139619c5