毎年変わる学年と年齢を自動更新する(カスタム関数(Deluge Script)とワークフロー)

毎年変わる学年と年齢を自動更新する(カスタム関数(Deluge Script)とワークフロー)

学年/年齢項目を用意


誕生日起算で実行するワークフローを設定


引数を設定


  1. //年齢更新
  2. //今日日付をYYYYMMDDに変換
  3. tm = toString(zoho.currentdate.getMonth());
  4. if(len(tm) == 1)
  5. {
  6. tma = "0" + tm;
  7. }
  8. else
  9. {
  10. tma = tm;
  11. }
  12. td = toString(zoho.currentdate.getDay());
  13. if(len(td) == 1)
  14. {
  15. tda = "0" + td;
  16. }
  17. else
  18. {
  19. tda = td;
  20. }
  21. nowd = toString(zoho.currentdate.getYear()) + tma + tda;
  22. //誕生日付をYYYYMMDDに変換
  23. bm = toString(birthDay.getMonth());
  24. if(len(bm) == 1)
  25. {
  26. bma = "0" + bm;
  27. }
  28. else
  29. {
  30. bma = bm;
  31. }
  32. bd = toString(birthDay.getDay());
  33. if(len(bd) == 1)
  34. {
  35. bda = "0" + bd;
  36. }
  37. else
  38. {
  39. bda = bd;
  40. }
  41. //
  42. nowb = toString(birthDay.getYear()) + bma + bda;
  43. //年齢算出式
  44. agedeci = (toDecimal(nowd) - toDecimal(nowb)) / 10000;
  45. age = floor(agedeci);
  46. //年齢算出したものを更新
  47. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"年齢":age}));
  48. //学年の算出
  49. //日付算出
  50. birthd = birthDay.getMonth() + "-" + birthDay.getDay() + "-" + zoho.currentdate.getYear();
  51. ap = "4" + "-" + "1" + "-" + zoho.currentdate.getYear();
  52. //誕生日が4月以降だった場合は0、4月1日より前の場合は1を+させる
  53. if(birthd.toDate() > ap.toDate())
  54. {
  55. i = 0;
  56. }
  57. else
  58. {
  59. i = 1;
  60. }
  61. //年齢による学年算出式
  62. gakunen = zoho.currentdate.getYear() - birthDay.getYear() + i;
  63. if(gakunen == 7)
  64. {
  65. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学1年生"}));
  66. }
  67. else if(gakunen == 8)
  68. {
  69. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学2年生"}));
  70. }
  71. else if(gakunen == 9)
  72. {
  73. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学3年生"}));
  74. }
  75. else if(gakunen == 10)
  76. {
  77. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学4年生"}));
  78. }
  79. else if(gakunen == 11)
  80. {
  81. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学5年生"}));
  82. }
  83. else if(gakunen == 12)
  84. {
  85. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学6年生"}));
  86. }
  87. else if(gakunen == 13)
  88. {
  89. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学1年生"}));
  90. }
  91. else if(gakunen == 14)
  92. {
  93. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学2年生"}));
  94. }
  95. else if(gakunen == 15)
  96. {
  97. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学3年生"}));
  98. }
  99. else
  100. {
  101. res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"不明"}));
  102. }
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方