patrickjust3k

showingtime importation of data

Aug 31st, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. //get mail record
  2. mailDetails = zoho.crm.getRecordById("mail_data",mailId.toLong());
  3. //get subject and body
  4. mail_subject = ifnull(mailDetails.get("Subject"),"");
  5. mail_body = ifnull(mailDetails.get("MailBody"),"");
  6. //info "mail body : " + mail_body;
  7. //info "mail subject: " + mail_subject;
  8. //get address
  9. address = mail_subject.substring(20);
  10. address = address.getPrefix(",");
  11. address = address.subString(0,10);
  12. info "address : " + address;
  13. //get date from email body
  14. date_long = mail_body.getSuffixIgnoreCase("Appointment Details");
  15. date_after_showing = date_long.getSuffixIgnoreCase("Showing");
  16. date_before_dash = date_after_showing.getPrefixIgnoreCase("-");
  17. date_tostring = date_before_dash.toString();
  18. date = date_tostring.getSuffixIgnoreCase(",");
  19. //convert date to correct format
  20. date = replaceAll(date,"January","01,");
  21. date = replaceAll(date,"Februaru","02,");
  22. date = replaceAll(date,"March","03,");
  23. date = replaceAll(date,"April","04,");
  24. date = replaceAll(date,"May","05,");
  25. date = replaceAll(date,"June","06,");
  26. date = replaceAll(date,"July","07,");
  27. date = replaceAll(date,"August","08,");
  28. date = replaceAll(date,"September","09,");
  29. date = replaceAll(date,"October","10,");
  30. date = replaceAll(date,"November","11,");
  31. date = replaceAll(date,"December","12,");
  32. date = replaceAll(date,"PM","");
  33. date = replaceAll(date,"AM","");
  34. date = date.subString(0,14);
  35. date = toDate(date,"MM,dd,yyyy");
  36. info "converted date : " + date;
  37. // get buyer agent name
  38. buyer_agent = mail_body.getSuffix("Buyer's Agent Details");
  39. buyer_agent = buyer_agent.subString(0,22);
  40. info "buyer agent: " + buyer_agent;
  41. //get buyer agent phone number
  42. buyer_phone = mail_body.getSuffix("Buyer's Agent Details");
  43. buyer_phone = mail_body.getSuffix("(");
  44. buyer_phone = buyer_phone.removeFirstOccurence(")");
  45. buyer_phone = buyer_phone.replaceAllIgnoreCase(" ","-");
  46. buyer_phone = buyer_phone.subString(0,12);
  47. info "buyer phone : " + buyer_phone;
  48. //get buyer agent email
  49. buyer_email = mail_body.getSuffixIgnoreCase("(Office Main Line)");
  50. buyer_email = buyer_email.getPrefixIgnoreCase("Listing");
  51. info "buyer email : " + buyer_email;
  52. //find deal id mathcing address
  53. deal_search = zoho.crm.searchRecords("Deals","Deal_Address:starts_with:" + address);
  54. //info "deal --- > " + deal_search;
  55. if(deal_search.isEmpty())
  56. {
  57. sendmail
  58. [
  59. from :zoho.adminuserid
  60. subject :"Function loading showingtime into Zoho is broken"
  61. message :"<div>The function for loading showingtime info into zoho is broken.</div>"
  62. ]
  63. }
  64. else
  65. {
  66. deal_id = deal_search.getJSON("id");
  67. deal_details = zoho.crm.getRecordById("Deals",deal_id);
  68. deal_owner = deal_details.getJSON("Owner").get("id");
  69. info "deal owner: " + deal_owner;
  70. info "deal id: " + deal_id;
  71. mailmap = Map();
  72. mailmap.put("Name",ifnull(buyer_agent,""));
  73. mailmap.put("Date_1",ifnull(date,""));
  74. mailmap.put("Phone_1",buyer_phone);
  75. mailmap.put("Inquiries Owner",ifnull("Patrick Kaiser",""));
  76. mailmap.put("Email",ifnull(buyer_email,""));
  77. mailmap.put("Inquired_on",{"id":deal_id});
  78. mailmap.put("Source","ShowingTime");
  79. mailmap.put("Status","Showed");
  80. mailcreate = zoho.crm.createRecord("Inquiry",mailmap);
  81. info mailcreate;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment