Cスクリプトを利用して年齢を即時に算出する

Cスクリプトを利用して年齢を即時に算出する

あらかじめ連絡先タブに項目=年齢(API name = Nenrei)を追加


let birth = ZDK.Page.getField('Date_of_Birth');
let birthd = birth.getValue();

// 誕生日を保持したDateインスタンスを生成
var birthday = new Date(birthd);
// 今日の日付を保持したDateインスタンスを生成
var today = new Date();

// 現在の年から誕生年を減算
var age = today.getFullYear() - birthday.getFullYear();

// 現在の年で誕生日が来ていなければ減算
if ( today < birthday.setFullYear( today.getFullYear() ) ){
age--;
}
let agedate = ZDK.Page.getField('Nenrei');
agedate.setValue(age);

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now