- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 12:35 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 02:56 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 12:51 AM
Hi there,
Try this, it's tested.
var comm = gr.comments.getJournalEntry(1); //get the latest comment // gr can be replaced based on your your script
var userName = comm.split('(Additional comments)\n')[0].split('-')[3];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2023 11:07 PM
Thanks, it perfectly gave the user name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 12:59 AM
Hi,
can you share what script you tried?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 01:01 AM
Hi Ankur,
I tried below script
business rules written on sc_task on after update
var addinfousr = current.u_additional_information.getDisplayValue();
gs.log("additional user information:::"+addinfousr);
var com = current.comments.getJournalEntry(1);
gs.log("latest comments:::"+com);
var userName = com.split('(Additional comments)\n')[0].split('-')[3];
gs.log("username from latest comments:::"+userName +addinfousr);
if(userName == addinfousr)
{
gs.log("inside the latest update from add info if statement:::");
current.state='2';
current.update();
}
every logs working except inside the if statement,
Please help with the condition
if(userName == addinfousr)
Please help!
Thanks,
Sri
Regards,
Snehangshu Sarkar
Please mark my answer as correct if it resolves your query.