Script to send last note added along with its contents to requesters- Servicedesk Plus MSP

Script to send last note added along with its contents to requesters- Servicedesk Plus MSP

How it works?

A report will be scheduled to run at a periodic interval which will fetch he details of the request. Once the schedules runs, the script will fetch the values from the report and sends an notification through email to the requester of the request where the note is added. 

What is Custom Schedule?

Custom Schedules are actions scheduled on a specific date and time with or without repeat frequency. The actions are specified in a customized script file. Any data from ServiceDesk Plus can be sent to the script through Query Reports.
Create a new custom schedule with a unique Schedule Name. Mention the command to execute the script in the Executor field. Associate the required Query Reports as Arguments. Mention the Start Date & Time at when the action should take place. Schedule the action by specifying the Repeat interval. Enable/Disable a custom schedule as preferred.
Instructions 

1. Extract the attached files under ManageEngine\ServiceDeskPlus-MSP\integration\custom_scripts

2. Edit the configuration.json with the mail server details. 

3. Navigate to Reports>New Query Reports>> Run the below query 

select wo.workorderid AS "Workorderid",
wo.TITLE AS "Subject", 
aau1.first_name AS "Note_Created_By", 
aau2.first_name AS "Requester",
AaaContactInfo.EMAILID AS "Email",
note.notestext AS "Notes",
to_timestamp(note.notesdate/1000) AS "Added_Time" from notes note LEFT JOIN aaauser aau1 on note.userid=aau1.user_id LEFT JOIN workorder wo on note.workorderid=wo.workorderid LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID LEFT JOIN AaaUser aau2 ON sdu.USERID=aau2.USER_ID LEFT JOIN AaaUserContactInfo ON aau2.USER_ID=AaaUserContactInfo.USER_ID  LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID=AaaContactInfo.CONTACTINFO_ID where note.NOTESID = (SELECT MAX(nts.NOTESID) FROM Notes nts WHERE nts.WORKORDERID=note.WORKORDERID and extract(epoch from(now()::TIMESTAMP -  to_timestamp(nts.notesdate/1000)::TIMESTAMP))/3600 < 1)  and  (wo.ISPARENT='1') group by wo.WORKORDERID,note.notestext,aau1.first_name,aau2.first_name,AaaContactInfo.EMAILID,note.notesdate


4 . Navigate to Admin>Custom Schedule>>> Fill the details 

The Executor field should be py sendMailRecentNotes.py

Select the report as argument 




Whenever the schedule runs, email notifications will be sent to the requester of the request where notes are added. 
                  New to ADManager Plus?

                    New to ADSelfService Plus?