script step within flow designer that pulls worknotes/comments into an array and selects the latest.

CandyDee
Kilo Sage

Can anyone help with the below

Write a script on the action (action is jira update comments action) such that if the action needs the latest comment put the values in an array and pick the latest- 

Basically im' trying to past across work comments using flow designer to Jira via integration hub. Im stuck on the guidance provided by servicenow.

I thought that expanding the script action on the 'comment' field of the action and inputting the script below was close but not getting there.

I can get snow stories being created in Jira using another flow i have, this is to pass worknotes across to update the comments of the jira issue.

find_real_file.png

 

 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi CandyDee,

Back to the original question.

"Add Comment" step is used to add a comment and not to retrieve them. Note, that there may be several comments and work notes attached to a record.

Following is a sample flow to retrieve comments and work notes attached to an incident.

This is the general flow. (1) First, I'm retrieving and incident record using "Look Up Record" step. (2) Then using "Look Up Records" to get all comments and work notes. (3) Then looping through the retrieved records to get each comment and work note.

find_real_file.png

1. Using "Look Up Record" to retrieve a record with comments or work notes. Not sure from the question which record is being retrieved because the trigger is on Service Catalog but mentions Integration Hub. This step should be changed to get the record to retrieve .

find_real_file.png

2. Retrieve comments and work notes related to the record. "Name" is the name of the table. In the example, I'm getting comments and work notes related to an incident table so have "Incident". Should change to fit the requirement.

"Element ID" is the sys_id of the record. Using data pill to get the "sys_id" from the retrieved record in step 1.

"Element" is type of journal records. I want to get "work_notes" and "comments" here.

find_real_file.png

3. There may be several comments and work notes related to a record to using "For Each Item in" step to get individual record returned in step 2. Used data pill to set Item to "journal Entry Records".

find_real_file.png

4. I'm just using a log statement here to log each comment and work note. Comment and work note is in field "Value". Using data pill to set Message to "Value" field under "journal Entry Record".

find_real_file.png

 

View solution in original post

7 REPLIES 7

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi CandyDee,

Back to the original question.

"Add Comment" step is used to add a comment and not to retrieve them. Note, that there may be several comments and work notes attached to a record.

Following is a sample flow to retrieve comments and work notes attached to an incident.

This is the general flow. (1) First, I'm retrieving and incident record using "Look Up Record" step. (2) Then using "Look Up Records" to get all comments and work notes. (3) Then looping through the retrieved records to get each comment and work note.

find_real_file.png

1. Using "Look Up Record" to retrieve a record with comments or work notes. Not sure from the question which record is being retrieved because the trigger is on Service Catalog but mentions Integration Hub. This step should be changed to get the record to retrieve .

find_real_file.png

2. Retrieve comments and work notes related to the record. "Name" is the name of the table. In the example, I'm getting comments and work notes related to an incident table so have "Incident". Should change to fit the requirement.

"Element ID" is the sys_id of the record. Using data pill to get the "sys_id" from the retrieved record in step 1.

"Element" is type of journal records. I want to get "work_notes" and "comments" here.

find_real_file.png

3. There may be several comments and work notes related to a record to using "For Each Item in" step to get individual record returned in step 2. Used data pill to set Item to "journal Entry Records".

find_real_file.png

4. I'm just using a log statement here to log each comment and work note. Comment and work note is in field "Value". Using data pill to set Message to "Value" field under "journal Entry Record".

find_real_file.png

 

This is incredibly helpful. Its defo something I can take away and reuse for other flow designer stuff. Really cool bit of work. 

The issue im having with regards to passing the comment to jira is below. The log action is getting the most recent update which is exactly what I want but for some reason the Jira action isnt taking the message output from the log step.

Its putting into the comments 'success' and but it is updating the jira issue with 'success' which it wasnt doing before hahaha.

 

sorted it,