カスタム関数:郵便番号を元に住所情報を更新する

カスタム関数:郵便番号を元に住所情報を更新する

対象タブは見込み客、連絡先、取引先の3つでございますが、
各タブでカスタム関数が所々異なっております。ご了承ください。

見込み客編
引数
recordID =  「見込み客」の「見込み客のID」
zipCode =  「見込み客」の「郵便番号」

関数の内容
zipRes = getUrl("http://zipcloud.ibsnet.co.jp/api/search?zipcode=" + input.zipCode);
prefecture = zipRes.executeXPath("/root/results/address1/text()");
city = zipRes.executeXPath("/root/results/address2/text()");
street = zipRes.executeXPath("/root/results/address3/text()");
mp=map();
mp.put("State",prefecture);
mp.put("City",city);
mp.put("Street",street);
resp = zoho.crm.updateRecord("Leads",recordID,mp); 

上記の関数をワークフローで呼び出すように設定してください。

オススメのワークフローの設定
実行するタイミング:追加/編集 もしくは 項目更新(「郵便番号」)
条件:「郵便番号」「が空でない」


連絡先編
引数
recordID =  「連絡先」の「連絡先のID」
zipCode =  「連絡先」の「郵便番号」

関数の内容
prefecture = zipRes.executeXPath("/root/results/address1/text()");
city = zipRes.executeXPath("/root/results/address2/text()");
street = zipRes.executeXPath("/root/results/address3/text()");
mp = Map();
mp.put("Mailing_State",prefecture);
mp.put("Mailing_City",city);
mp.put("Mailing_Street",street);
resp = zoho.crm.updateRecord("Contacts",recordID,mp);

上記の関数をワークフローで呼び出すように設定してください。

オススメのワークフローの設定
実行するタイミング:追加/編集 もしくは 項目更新(「郵便番号」)
条件:「郵便番号」「が空でない」

取引先編
引数
recordID =  「取引先」の「取引先のID」
zipCodeShipping =  「取引先」の「郵便番号(納品先)」
zipCodeBilling =  「取引先」の「郵便番号(請求先)」

関数の内容
zipRes1 = getUrl("http://zipcloud.ibsnet.co.jp/api/search?zipcode=" + zipCodeShipping);
prefecture = zipRes1.executeXPath("/root/results/address1/text()");
city = zipRes1.executeXPath("/root/results/address2/text()");
street = zipRes1.executeXPath("/root/results/address3/text()");
mp = Map();
mp.put("Shipping_State",prefecture);
mp.put("Shipping_City",city);
mp.put("Shipping_Street",street);
zipRes2 = getUrl("http://zipcloud.ibsnet.co.jp/api/search?zipcode=" + zipCodeBilling);
prefecture = zipRes2.executeXPath("/root/results/address1/text()");
city = zipRes2.executeXPath("/root/results/address2/text()");
street = zipRes2.executeXPath("/root/results/address3/text()");
mp.put("Billing_State",prefecture);
mp.put("Billing_City",city);
mp.put("Billing_Street",street);
resp = zoho.crm.updateRecord("Accounts",recordID,mp);

上記の関数をワークフローで呼び出すように設定してください。

オススメのワークフローの設定
実行するタイミング:
 追加/編集 もしくは 項目更新(「郵便番号(納品先)」、「郵便番号(請求先)」のいずれか)

条件:
 (1)「郵便番号(納品先)」「が空でない」
  または
 (2)「郵便番号(請求先)」「が空でない」

今回用いたAPIについて
郵便番号から住所情報を取得するために外部のAPIを使用しています。
同様のAPIは複数ありますが、上記のサンプルでは以下のサイトのAPIを利用しています。
郵便番号検索API
こちらのAPIについての動作を保証することはできかねますのでご了承ください。
また、ご利用になる場合は、APIの利用規約等にしたがってください。



    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner






                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator 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


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方