Good day SDP Community,
We are attempting to use this custom function to handle the automated emails we receive from our internal PRTG architecture. (PRTG is network monitoring software & sends emails when network assets fall offline and when they reconnect.)
These generated emails are then picked up by Business rules to further facilitate the handling of the created ticket. We use email parsing commands example: (@@Template = PRTG@@) to drive the template, mode, and other details of the incoming ticket.
We have a business rule that takes the email from PRTG when an asset has restored connection and automatically closes the original ticket for the device being offline. The code for that custom function is:
- alertIdentificationUdfKey = "udf_char149";
- closure_code = "PRTG Auto Close";
- /*Please provide the description of the note content*/
- noteDescription = "The alert has been cleared in PRTG, hence closing the request";
- deviceId = requestObj.get("udf_fields").get(alertIdentificationUdfKey);
- requests = zoho.sdp.invokeurl
- [
- url :"/app/" + context.get("instance") + "/api/v3/requests"
- type :GET
- parameters:{"input_data":{"list_info":{"search_criteria":{{"field":"udf_fields." + alertIdentificationUdfKey,"condition":"contains","values":{deviceId},"logical_operator":"AND"},{"field":"status.in_progress","condition":"is","value":true,"logical_operator":"AND"}},"row_count":1,"sort_fields":{{"field":"display_id","order":"desc"}}}}}
- ];
- info requests;
- if(requests.get("requests") != null && requests.get("requests").size() > 0)
- {
- requestId = requests.get("requests").get(0).get("id");
- closeRequest = zoho.sdp.invokeurl
- [
- url :"/app/" + context.get("instance") + "/api/v3/requests/" + requestId
- type :PUT
- parameters:{"input_data":{"request":{"status":{"name":"Closed"},"closure_info":{"closure_code":{"name":closure_code}}}}}
- ];
- if(closeRequest.get("request") != null)
- {
- addNote = zoho.sdp.invokeurl
- [
- url :"/app/" + context.get("instance") + "/api/v3/requests/" + requestId + "/notes"
- type :POST
- parameters:{"input_data":{"request_note":{"description":noteDescription}}}
- ];
- }
- }
- return requestObj;
^This code currently works perfectly**
What we want to know is, if it's possible to add a "timer or countdown" element to this code.
Essentially, we want to execute the above script of "auto-closing the PRTG ticket" only if the "returned to Online status" email is received within a given time frame.
Example:
Ticket for Server XYZ failing to respond to ping is created at 12:00 local time, if the email from PRTG is received within 15 minutes (on or before 12:15 local time) we want to execute the code above.
If the email from PRTG is received after the 15-minute mark (on or after 12:16 local time) - do not execute the above code.
*The time of ticket creation" is irrelevant the variable we want to use is the "time frame" ex. (15-minutes not a specific set of times of the day) we'd like to add into the code.
Any and all help is greatly appreciated!
Best Regards,
Bradley