毎年変わる学年と年齢を自動更新する(カスタム関数(Deluge Script)とワークフロー)
学年/年齢項目を用意
誕生日起算で実行するワークフローを設定
引数を設定
- //年齢更新
- //今日日付をYYYYMMDDに変換
- tm = toString(zoho.currentdate.getMonth());
- if(len(tm) == 1)
- {
- tma = "0" + tm;
- }
- else
- {
- tma = tm;
- }
- td = toString(zoho.currentdate.getDay());
- if(len(td) == 1)
- {
- tda = "0" + td;
- }
- else
- {
- tda = td;
- }
- nowd = toString(zoho.currentdate.getYear()) + tma + tda;
- //誕生日付をYYYYMMDDに変換
- bm = toString(birthDay.getMonth());
- if(len(bm) == 1)
- {
- bma = "0" + bm;
- }
- else
- {
- bma = bm;
- }
- bd = toString(birthDay.getDay());
- if(len(bd) == 1)
- {
- bda = "0" + bd;
- }
- else
- {
- bda = bd;
- }
- //
- nowb = toString(birthDay.getYear()) + bma + bda;
- //年齢算出式
- agedeci = (toDecimal(nowd) - toDecimal(nowb)) / 10000;
- age = floor(agedeci);
- //年齢算出したものを更新
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"年齢":age}));
- //学年の算出
- //日付算出
- birthd = birthDay.getMonth() + "-" + birthDay.getDay() + "-" + zoho.currentdate.getYear();
- ap = "4" + "-" + "1" + "-" + zoho.currentdate.getYear();
- //誕生日が4月以降だった場合は0、4月1日より前の場合は1を+させる
- if(birthd.toDate() > ap.toDate())
- {
- i = 0;
- }
- else
- {
- i = 1;
- }
- //年齢による学年算出式
- gakunen = zoho.currentdate.getYear() - birthDay.getYear() + i;
- if(gakunen == 7)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学1年生"}));
- }
- else if(gakunen == 8)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学2年生"}));
- }
- else if(gakunen == 9)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学3年生"}));
- }
- else if(gakunen == 10)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学4年生"}));
- }
- else if(gakunen == 11)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学5年生"}));
- }
- else if(gakunen == 12)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"小学6年生"}));
- }
- else if(gakunen == 13)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学1年生"}));
- }
- else if(gakunen == 14)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学2年生"}));
- }
- else if(gakunen == 15)
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"中学3年生"}));
- }
- else
- {
- res = zoho.crm.updateRecord("contacts",leadID.toString(),Map:String({"学年":"不明"}));
- }
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
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
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.