How to get username in latest additional comments

Sri56
Tera Contributor

Hi Team,

We are having requirement that we are having one field called add info (reference user field) so when there is an additional comment from this user we need to change the state to WIP.

currently i'm getting a latest comment in this format:

2022-04-27 09:21:27 - user1 (Additional comments)
tested ok

so here we need only user1 value to compare with add info field which we have created.

Please help with the code.

Thanks,

Sri

1 ACCEPTED SOLUTION

Hi,

update as this

var addinfousr = current.u_additional_information.getDisplayValue();
gs.log("additional user information:::"+addinfousr);
var com = current.comments.getJournalEntry(1);
if(com.indexOf(addinfousr) > -1)
{
    gs.log("inside the latest update from add info if statement:::");
    current.state='2';
    current.update();
}

Regards
Ankur

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

View solution in original post

5 REPLIES 5

Hi,

update as this

var addinfousr = current.u_additional_information.getDisplayValue();
gs.log("additional user information:::"+addinfousr);
var com = current.comments.getJournalEntry(1);
if(com.indexOf(addinfousr) > -1)
{
    gs.log("inside the latest update from add info if statement:::");
    current.state='2';
    current.update();
}

Regards
Ankur

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