I want to use the rejection comment within the workflow.

bonsai
Mega Sage

I want to copy the rejection comment for a requested item into a field in a separate table.

Since the rejection comment is recorded in a "Journal" type field, retrieving it within a flow includes unwanted extra information.

Is there a way to retrieve *only* the comment itself?
It would be ideal if it were managed in a specific table somewhere...

I would like to resolve this using flow actions rather than scripts.

1 ACCEPTED SOLUTION

@bonsai 

I am suggesting to use GlideRecord in set flow variables flow logic

what did you try? share screenshots

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

View solution in original post

9 REPLIES 9

Tanushree Maiti
Tera Patron

Hi @bonsai 

 

You can  use the .getJournalEntry(1 ) method to parse out just the newest comment without dates or user details.

 

Use a Run Script or Script step in your flow with the following Script:

 

var currentItem = fd_data.trigger.current;

var latestComment = currentItem.comments.getJournalEntry( 1); // dont give space before 1

currentItem.setValue('u_your_custom_field', latestComment); // Populate the separate field/table (use glide record) with this extracted text

 

Refer: https://www.servicenow.com/community/virtual-agent-forum/execute-flow-when-comment-is-added-to-an-in...

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Ankur Bawiskar
Tera Patron

@bonsai 

after the approval step use Lookup record step on sys_journal_field with query like this and grab the Value column which gives you the text entered

Element ID = sysapproval_approver record sysid

Then use the output from this step and do whatever you need to do as per business requirement

AnkurBawiskar_0-1784219791136.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

The rejection comment (intended for the widget displayed on the portal) was recorded in the "Comments" field of the Requested Item record (where the name is `sc_req_item`).

bonsai_1-1784267895726.png

 

 

Additionally, when I attempted to set a filter targeting the "Element" field within a flow action, a message appeared stating that the "Element" field is not supported, preventing me from using it.

bonsai_2-1784267944220.png

 

 

As a workaround, I tried setting only the filter conditions for the "Look Up Record" action via a script, but this was unsuccessful.

The following error occurred:
"GlideRecord.setTableName - empty table name"

 

bonsai_0-1784267830577.png

 

 

@bonsai 

another workaround

1) create a flow variable of type string

2) after approval step use "Set Flow variables" flow logic and use GlideRecord to grab the value and set in that flow variable

3) then use the flow variable which now holds the exact value

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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