ticket_resp = zoho.desk.getRecordById("<OrgId>","tickets",ticket_id); info "ticket_resp: " + ticket_resp; description = ticket_resp.get("subject"); customer_email = ticket_resp.get("email"); search_resp = invokeurl [ url :"https://fsm.zoho.com/fsm/v1/Contacts/search?api_name=Email&value=" + customer_email type :GET connection:"fsmconnection" ]; info "search_resp: " + search_resp; if(search_resp == "" || search_resp == null) { desk_contact_search_resp = zoho.desk.searchRecords("<OrgId>","Contacts",{"email":customer_email}); desk_contact_search_data = desk_contact_search_resp.get("data").toMap(); contact_create_Map = Map(); contact_create_Map.put("Salutation","Mr."); contact_create_Map.put("First_Name",desk_contact_search_data.get("firstName")); contact_create_Map.put("Last_Name",desk_contact_search_data.get("lastName")); contact_create_Map.put("Email",desk_contact_search_data.get("email")); contact_create_Map.put("Phone",desk_contact_search_data.get("phone")); contact_create_Map.put("Mobile",desk_contact_search_data.get("mobile")); contact_Service_Address_Map = Map(); contact_Service_Address_Map.put("Address_Name",desk_contact_search_data.get("lastName") + " Shipping Address"); contact_Service_Address_Map.put("Street_1",desk_contact_search_data.get("street")); contact_Service_Address_Map.put("City",desk_contact_search_data.get("city")); contact_Service_Address_Map.put("State",desk_contact_search_data.get("state")); contact_Service_Address_Map.put("Zip_Code",desk_contact_search_data.get("zip")); contact_Service_Address_Map.put("Country",desk_contact_search_data.get("country")); contact_Billing_Address_Map = Map(); contact_Billing_Address_Map.put("Address_Name",desk_contact_search_data.get("lastName") + " Billing Address"); contact_Billing_Address_Map.put("Street_1",desk_contact_search_data.get("street")); contact_Billing_Address_Map.put("City",desk_contact_search_data.get("city")); contact_Billing_Address_Map.put("State",desk_contact_search_data.get("state")); contact_Billing_Address_Map.put("Zip_Code",desk_contact_search_data.get("zip")); contact_Billing_Address_Map.put("Country",desk_contact_search_data.get("country")); contact_create_Map.put("Service_Address",contact_Service_Address_Map); contact_create_Map.put("Billing_Address",contact_Billing_Address_Map); cr_resp = zoho.fsm.createRecord("Contacts",contact_create_Map); customer_id = cr_resp.get("data").toMap().get("Contacts").toMap().get("id"); } else { customer_id = search_resp.get("data").toMap().get("id"); } customer_resp = zoho.fsm.getRecordById("Contacts",customer_id); customer_data = customer_resp.get("data").toMap(); Billing_Address_Map = customer_data.get("Billing_Address").toMap(); if(Billing_Address_Map != null) { billing_Address_map = Map(); billing_Address_map.put("id",Billing_Address_Map.get("id")); billing_Address_map.put("Billing_Street_1",Billing_Address_Map.get("Street_1")); billing_Address_map.put("Billing_Street_2",Billing_Address_Map.get("Street_2")); billing_Address_map.put("Billing_City",Billing_Address_Map.get("City")); billing_Address_map.put("Billing_State",Billing_Address_Map.get("State")); billing_Address_map.put("Billing_Country",Billing_Address_Map.get("Country")); billing_Address_map.put("Billing_Zip_Code",Billing_Address_Map.get("Zip_Code")); } Service_Address_Map = customer_data.get("Service_Address").toMap(); if(Service_Address_Map != null) { service_Address_map = Map(); service_Address_map.put("id",Service_Address_Map.get("id")); service_Address_map.put("Service_Street_1",Service_Address_Map.get("Street_1")); service_Address_map.put("Service_Street_2",Service_Address_Map.get("Street_2")); service_Address_map.put("Service_City",Service_Address_Map.get("City")); service_Address_map.put("Service_State",Service_Address_Map.get("State")); service_Address_map.put("Service_Country",Service_Address_Map.get("Country")); service_Address_map.put("Service_Zip_Code",Service_Address_Map.get("Zip_Code")); } terrResp = zoho.fsm.getRecords("Territories"); terrId = terrResp.get("data").toMap().get("id"); createMap = Map(); createMap.put("Summary",description); createMap.put("Contact",customer_id); createMap.put("Priority","Medium"); createMap.put("Billing_Address",billing_Address_map); createMap.put("Service_Address",service_Address_map); createMap.put("Territory", terrId); response = zoho.fsm.createRecord("Requests",createMap); new_rec_id = response.get("data").toMap().get("Requests").toMap().get("id"); up_map = Map(); up_map.put("<custom_field_api_name>",ticket_id.toString()); up_resp_res = zoho.fsm.updateRecord("Requests",new_rec_id,up_map); info up_resp_res; |
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.