Send notification based on custom date additional field using Python Script

Send notification based on custom date additional field using Python Script

1.Download the contents and paste it under \ManageEngine\ServiceDeskPlus-MSP\integrations\Custom_scripts.

2.Go to Reports tab --> New query report --> copy the query to the query editor and run the report. Save the report in the folder. 


SELECT wo.WORKORDERID AS "workorderid", wo.TITLE AS "subject", aau.FIRST_NAME AS "requester",(AaaContactInfo.EMAILID) "emailid",wof.UDF_DATE1 AS "vendor_collectiondate" FROM WorkOrder wo LEFT JOIN WorkOrder_Fields wof ON wo.WORKORDERID=wof.WORKORDERID 
INNER JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID  
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID 
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID 
LEFT JOIN AaaUserContactInfo ON aau.USER_ID=AaaUserContactInfo.USER_ID 
LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID=AaaContactInfo.CONTACTINFO_ID  
left join statusdefinition std on wos.statusid=std.statusid WHERE (wo.ISPARENT='1') and std.ispending='1' and 
extract(epoch from( to_timestamp(wof.UDF_DATE1/1000)::TIMESTAMP - now()::TIMESTAMP))/3600/24 = 0

The above query is for Postgres Database. If you're using MSSQL, please use the below query:

SELECT wo.WORKORDERID AS "workorderid", wo.TITLE AS "subject", aau.FIRST_NAME AS "requester",(AaaContactInfo.EMAILID) "emailid",longtodate(wof.UDF_DATE1) AS "vendor_collectiondate" FROM WorkOrder wo LEFT JOIN WorkOrder_Fields wof ON wo.WORKORDERID=wof.WORKORDERID INNER JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID LEFT JOIN AaaUserContactInfo ON aau.USER_ID=AaaUserContactInfo.USER_ID LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID=AaaContactInfo.CONTACTINFO_ID left join statusdefinition std on wos.statusid=std.statusid WHERE (wo.ISPARENT='1') and std.ispending='1' and DATEDIFF(day, dateadd(s,datediff(s,GETUTCDATE(),getdate())+(wof.UDF_DATE1/1000),'1970-01-01 00:00:00'),GETDATE()) =0


Note: I have specified wof.UDF_DATE1 as an example. You can check the exact  name of the Column under Admin --> Incident Additional Fields
3. In the configuration.json, configure the outgoing mail server settings , url and technician key.

Note:

Verify the query before scheduling. It should list the requests for the date additional fields that are same as today's date.

4. Go to Admin --> Custom Schedules and create a schedule by selecting the report and specifying the script like below:





A short guide on setting up python is available here :


Refer to the link below in order to setup the custom schedule:

https://help.servicedeskplus.com/configurations/general/custom_schedules.html

                  New to ADManager Plus?

                    New to ADSelfService Plus?