Check if P1 INC is being updated evry 1hr, if not Send an email notify to the manager of Assigned to

saipragna
Tera Contributor

When the P1 INC work notes/ comments are not updated every 1 hour, email should be sent to the manager of Assigned to user. Can someone help me to achieve this.

 

Thank you

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @saipragna ,

You can achieve this using a Flow. Create a flow which will be attached to the P1 incidents and wait for an hour and check if there is an update in work notes/comments or not in last 1 hour and trigger an email to the manager if there is no update. You can try this approach,


1. Create a Flow Action which returns the difference between input time and current time, like the one below.

AnveshKumarM_0-1678167349823.png

AnveshKumarM_1-1678167391018.png

AnveshKumarM_2-1678167415816.png

AnveshKumarM_3-1678167457075.png

Use the below script in script step of the action.

(function execute(inputs, outputs) {
  var current_time = new GlideDateTime();
  var diffSeconds = gs.dateDiff(inputs.last_updated, current_time, true);
  diffMins = diffSeconds/60;
  diffMins = Math.round(diffMins);
  outputs.diff = diffMins;

})(inputs, outputs);

2. Create a flow which will check for the last update on comments/worknotes every 10 minutes and triggers an email to assigned to manager if there is no update in last 1 hour.

AnveshKumarM_4-1678167577542.png

AnveshKumarM_5-1678167612108.png

2-A. Look up for last comments/worknotes in sys_journal_field table.

AnveshKumarM_7-1678167732201.png

2-B: Check if a valid record is returned.

AnveshKumarM_8-1678167791268.png

 

2-C: If a valid record is found, get the time difference between now and last comment updated time.

AnveshKumarM_9-1678167839745.png

2-D: Check if the time difference is more than 1 hour

AnveshKumarM_10-1678167878796.png

 

2-E: If the update is more than 1 hour, send an email to assigned to user manager.

AnveshKumarM_11-1678167949869.png

AnveshKumarM_12-1678167965777.png

2-F: Wait for 10 minutes before next iteration.

AnveshKumarM_13-1678168013900.png

2-G: If the incident is resolved, get out of the loop and end the flow.

AnveshKumarM_14-1678168053831.png

 

Please let me know, if you face any difficulties using this.

 

Thanks,

Anvesh

 

 

 

 

 

 

 

 

 

 

 

 

Thanks,
Anvesh

View solution in original post

9 REPLIES 9

AnveshKumar M
Tera Sage
Tera Sage

Hi @saipragna ,

You can achieve this using a Flow. Create a flow which will be attached to the P1 incidents and wait for an hour and check if there is an update in work notes/comments or not in last 1 hour and trigger an email to the manager if there is no update. You can try this approach,


1. Create a Flow Action which returns the difference between input time and current time, like the one below.

AnveshKumarM_0-1678167349823.png

AnveshKumarM_1-1678167391018.png

AnveshKumarM_2-1678167415816.png

AnveshKumarM_3-1678167457075.png

Use the below script in script step of the action.

(function execute(inputs, outputs) {
  var current_time = new GlideDateTime();
  var diffSeconds = gs.dateDiff(inputs.last_updated, current_time, true);
  diffMins = diffSeconds/60;
  diffMins = Math.round(diffMins);
  outputs.diff = diffMins;

})(inputs, outputs);

2. Create a flow which will check for the last update on comments/worknotes every 10 minutes and triggers an email to assigned to manager if there is no update in last 1 hour.

AnveshKumarM_4-1678167577542.png

AnveshKumarM_5-1678167612108.png

2-A. Look up for last comments/worknotes in sys_journal_field table.

AnveshKumarM_7-1678167732201.png

2-B: Check if a valid record is returned.

AnveshKumarM_8-1678167791268.png

 

2-C: If a valid record is found, get the time difference between now and last comment updated time.

AnveshKumarM_9-1678167839745.png

2-D: Check if the time difference is more than 1 hour

AnveshKumarM_10-1678167878796.png

 

2-E: If the update is more than 1 hour, send an email to assigned to user manager.

AnveshKumarM_11-1678167949869.png

AnveshKumarM_12-1678167965777.png

2-F: Wait for 10 minutes before next iteration.

AnveshKumarM_13-1678168013900.png

2-G: If the incident is resolved, get out of the loop and end the flow.

AnveshKumarM_14-1678168053831.png

 

Please let me know, if you face any difficulties using this.

 

Thanks,

Anvesh

 

 

 

 

 

 

 

 

 

 

 

 

Thanks,
Anvesh

Hi Anvesh,

 

I'm having an error while I'm saving the flow action. 

saipragna_0-1678220433855.png

Not sure why this error is popping while I'm saving the flow. Can you please help?

 

Hi @saipragna ,

You have prefixed the output assignment with minutes, is intended? If it is not intended please remove that.

 

If it doesn't solve your problem, please send the screenshots of all steps in the action.

Note: FYI, I took the "diff" output variables in both Script Step and Outputs step is Integer.

 

AnveshKumarM_0-1678244935054.png

 

Thanks,
Anvesh

Hi Anvesh,

 

Yes, you're correct. I did a mistake. It is working as expected. Thank you so much.