/*---------------------------------------- Fetching work order information ------------------------------------------*/ work_order_id = work_order.get("id"); Status = work_order.get("Status"); work_order_resp = zoho.fsm.getRecordById("Work_Orders",work_order_id); work_order_data = work_order_resp.get("data").toMap(); woName = work_order_data.get("Name"); Billing_Status = work_order_data.get("Billing_Status"); Grand_Total = work_order_data.get("Grand_Total"); Summary = work_order_data.get("Summary"); Email = work_order_data.get("Email"); /*---------------------------------------- Fetching Contact information ------------------------------------------*/ ContactId = work_order_data.get("Contact").toMap().get("id"); ContactName = work_order_data.get("Contact").toMap().get("name"); contactResp = zoho.fsm.getRecordById("Contacts",ContactId); contactData = contactResp.get("data").toMap(); Mobile = contactData.get("Mobile"); /*---------------------------------------- Fetching Company information ------------------------------------------*/ company_name = organization.get("company_name"); /*---------------------------------------- Constructing message ------------------------------------------*/ if(Status == "Completed") { message = "Write your Custom message for completed status"; } if(Status == "New") { message = "Write your Custom message for new status"; } if(Status == "In Progress") { message = "Write your Custom message for in progress status"; } if(Status == "Cannot Complete") { message = "Write your Custom message for cannot complete status"; } if(Status == "Scheduled Appointment") { message = "Write your Custom message for scheduled appointment status"; } if(Status == "Cancelled") { message = "Write your Custom message for cancelled status"; } if(Status == "Closed" && Billing_Status == "Paid") { message = "Dear " + ContactName + ", Thank you for trusting " + company_name + " and giving us an oppurtunity to help you with " + Summary + ". We have received your payment of $" + Grand_Total + ". We are looking forward to serve you again in future. Thank you"; } if(Status == "Dispatched") { message = "Write your Custom message for dispatched status"; } /*---------------------------------------- Code to send Email ------------------------------------------*/ sendmail [ from :zoho.adminuserid to :Email subject :"Status of " + woName + " changed" message :message ] info "Email sent"; |