-
Notifications
You must be signed in to change notification settings - Fork 0
/
onCSchedule
76 lines (76 loc) · 1.69 KB
/
onCSchedule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
resp = crmAPIRequest;
parameters = resp.get("body").toString();
paramPairs = parameters.toList("&");
for each pair in paramPairs
{
fieldNames = pair.toList("=");
if(fieldNames.get(0) == "action")
{
eventType = fieldNames.get(1);
}
else if(fieldNames.get(0) == "id")
{
appointmentId = fieldNames.get(1);
}
}
debugVal = zoho.crm.getOrgVariable("acuityscheduling1__debug");
choosenActivity = zoho.crm.getOrgVariable("acuityscheduling1__activities");
if(debugVal = "no")
{
debug = false;
}
else if(debugVal = "yes")
{
debug = true;
}
if(debug)
{
sendmail
[
from :zoho.adminuserid
to :zoho.loginuserid
subject :"Cancelling"
message :"resp : " + resp
]
}
if(eventType == "appointment.canceled")
{
zEventMap = Map();
zEventMap.put("module",choosenActivity);
//use just column name
if(choosenActivity == "Events")
{
zEventMap.put("criteria","acuityscheduling1__AcuityID:equals:" + appointmentId);
}
if(choosenActivity == "Tasks")
{
zEventMap.put("criteria","acuityscheduling1__AcuityID:equals:" + appointmentId);
}
zEventResp = zoho.crm.invokeConnector("crm.search",zEventMap);
zEventResponse = zEventResp.get("response");
info zEventResponse;
if(zEventResponse != "")
{
if(debug)
{
sendmail
[
from :zoho.adminuserid
to :zoho.loginuserid
subject :"zEventResp"
message :"zEventResp : " + zEventResp
]
}
exEventMap = zEventResp.get("response").toMap();
exEventDataList = exEventMap.get("data").toJSONList();
for each item in exEventDataList
{
eventId = item.get("id");
info eventId;
}
deleteVar = Map();
deleteVar = {"module":choosenActivity,"id":eventId};
deleteResp = zoho.crm.invokeConnector("crm.delete",deleteVar);
}
}
return "Success";