英語:"Troubleshooting Sample Code Snippets"日本語:"サンプルコードスニペットのトラブルシューティング"

英語:"Troubleshooting Sample Code Snippets"日本語:"サンプルコードスニペットのトラブルシューティング"

お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。

以下は、Zoho CreatorのiOS用SDKのさまざまなメソッドを使用する方法を示すコードスニペットです。

フィールドアクセスパスを構築する

FieldAccessPath は、必要な フィールド を必要な フォームにアクセスするのに役立ちます。構築方法は以下の通りです。

一般のフィールドについて:

FieldAccessPath.field(リンク名: <FieldLinkName>)


サブフィールド(複合フィールドの一部)の場合、例えば、名前のfirst_nameフィールド、または住所のcountryフィールドなど:

FieldAccessPath.compositeField(リンク名: <CompositeFieldLinkName>, サブフィールドリンク名: <SubFieldLinkName>)


サブフォーム内の通常のフィールドについて:

FieldAccessPath.subFormField(linkName: <SubFormLinkName>, entryId: <EntryId>, fieldLinkName: <FieldLinkName>)


複合フィールドのサブフィールド内では、 サブフォームのために:


FieldAccessPath.subFormCompositeField(linkName: <CompositeFieldLinkName>, subFormLinkName: <SubFormLinkName>, entryId: <EntryId>, subFieldLinkName: <SubFieldLinkName>)

 

フォームオブジェクトを取得する

レコードを追加する際にアクセスされたときに表示されるフォームオブジェクトを取得するには:


let formInfo = FormInfo(linkName: <FormLinkName>, displayName: <FormDisplayName>)
ZCFormAPIService.fetch(for: formInfo) { (workFlowChangeSetResult) in
    switch workFlowChangeSetResult {
      case .success(let changeSet)
        let form = changeSet.form
      case .failure(_):
        //Failure
      }
  }


レコードを編集するときに表示されるフォームオブジェクトを取得するには:


let formInfo = FormInfo(linkName: <FormLinkName>, displayName: <FormDisplayName>)
ZCFormAPIService.fetch(forRecordID: <RecordId>, reportLinkName: <ReportLinkName>, formInfo: <FormInfo>) { (result) in
      switch workFlowChangeSetResult {
        case .success(let changeSet):
          let form = changeSet.form
        case .failure(_):
          //Failure
      }
  }

 

フィールドからの選択肢を取得する

Zoho Creatorでは、次のフィールドタイプで選択肢が表示されます: ドロップダウン、 ラジオ、 マルチセレクト、 チェックボックス、 ルックアップ名前フィールドのプレフィックスサブフィールド、住所フィールドの国サブフィールドを参照してください。必要なフィールドのAccessPathを構築するために、このセクションを参照してください。レコードを追加するためにフォームにアクセスしたときにフィールドが表示する選択肢を取得するには:


// Check FieldAccessPath construction as reference
let fieldAccessPath = FieldAccess.field(linkName: <ChoiceFieldLinkName>)
ZCFormAPIService.fetchChoices(forSearchString: <SearchString>, of: fieldAccessPath, in: <form>, fromIndex: <FromIndex>) { (result) in
    switch result {
      case .success(let choices):
        //choices
      case .failure(_):
        //failure
      }
  }


レコードを編集するためにフォームにアクセスしたときにフィールドが表示する選択肢を取得するには:


let fieldAccessPath = FieldAccess.field(linkName: <ChoiceFieldLinkName>)
ZCFormAPIService.fetchChoices(withRecordID: <Record Id>, forReportLinkName: <ReportLinkName>, forSearchString: <Search String>, of: fieldAccessPath, in: <form>, fromIndex: <FromInde>) { (result) in
    switch result {
      case .success(let choices):
        //choices
      case .failure(_):
        //failure
      }
  }

 

フォームの送信

レコードを追加するフォームを送信するには:


ZCFormAPIService.submit(form: <Form>) { (result) in
    switch result {
      case .success(let response):
        //Submit response
      case .failure(let error):
        //Error
    }
  }


レコードを編集するためにフォームを提出するには:


ZCFormAPIService.updateRecord(withRecordID: <recordLinkID>, inReportLinkName: <ReportLinkName>,form: <Form>) { (result) in
    switch result {
      case .success(let response):
        //Submit response
      case .failure(let error):
        //Error
    }
}

 

フィールドの値を設定する

  1. 必要なフィールドのアクセスパスを構築してください。
  2. フォームからフィールドとインデックスを取得します:
    <form>.getFieldAndIndex(using: <fieldAccessPath>)// (field,index)
  3. フォームからフィールドとインデックスを取得します:
    <form>.getFieldAndIndex(using: <fieldAccessPath>)// (field,index)
  4. フォームからフィールドとインデックスを取得する:
    <form>.getFieldAndIndex(using: <fieldAccessPath>)// (field,index)
  5. フォームからフィールドとインデックスを取得します:
    <form>現在のフィールドの値を取得します: 
    <フィールド>.getValue()// InputValues
  6. フィールド
    • 単行メール数値パーセント10 進数通貨複数行リッチテキスト」「ノートを追加日付日時時間
      InputValues.textFieldValue(fieldValue:<あなたの入力>)
    • 値を設定するには、決定ボックスフィールドの値を設定します。
      InputValuesdecisionFieldValue(fieldValue: <boolean_value>)
    • ドロップダウン、 このテクニカルヘルプガイドを日本語に翻訳するため、Transcreatorとして活動していただきたいと思います。HTMLコンテンツに英語のテキストが含まれています。HTMLタグや属性を変更せず、追加のコンテンツを生成しないようにしてください。英語のテキストを他の言語に翻訳しないようにしてください。英語のテキストを丁寧でビジネス的な自然な表現で日本語に翻訳してください。ラジオ、 このガイドは、テクニカルヘルプを提供するために作成されました。このガイドでは、問題を解決するための手順を説明します。まず、特定のソフトウェアに関する問題を解決するために必要な情報を提供します。次に、問題を解決するための最良の方法を提供します。最後に、問題を解決するための詳細な手順を提供します。このガイドをご覧いただき、ありがとうございます。検索 ユーザー統合
      
      if case InputValues.singleSelectChoiceFieldValue(var existingValue) = <field>.getValue() {
         existingValue.selectedChoice = { you can select appropriate value from existingValue.choice  }
         let newField = field.setValueFor(value: existingValue) //updated field
      }
      
    • チェックボックス、 このテクニカルヘルプガイドを日本語に翻訳するため、Transcreatorとして活動してください。HTMLコンテンツに英語のテキストが含まれています。英語のテキストを丁寧で、ビジネスに適した自然な言葉で日本語に翻訳してください。HTMLタグや属性を変更しないでください。また、追加のコンテンツを生成しないでください。英語のテキストが他の言語に翻訳されないようにしてください。複数選択、または 検索
      
      if case InputValues.multiSelectChoiceFieldValue(var existingValue) = <field>.getValue() {
         existingValue.selectedChoice = { you can select appropriate value from existingValue.choice  }
         let newField = field.setValueFor(value: existingValue) //updated field
      }
      
    • 電話番号
      
      let newField = field.setValueFor(value: InputValues.phoneNumberFieldValue(countryCode:<Code>,number: <PhoneNumber>))
      
    • URL
      
      let newField = field.setValueFor(value: InputValues.urlFieldValue(url:<url>,title:<title>,linkName:<linkName>))
      
  7. フィールドを次の形式で更新します:
    <フォーム>.setField(更新されたフィールド,インデックス: at)

メディアフィールドにファイルをアップロードし、フォームを送信する

レコードを追加するために、画像ファイルアップロードオーディオビデオ、または署名フィールドにファイルをアップロードしてフォームを送信します。


func submitMediaField(media: Data,filename:String ,fieldLinkName: String){
        let formInfo = FormInfo(linkName: '<formLinkName>', displayName: '<formDisplayName>', appLinkName: '<AppLinkName>', appOwner: '<AppOwner>', openUrlInfo: nil)
    // fetch form
        ZCFormAPIService.fetch(for: formInfo) { result in
            switch result {
            case .failure(let error):
                print(error)
            case .sucess(let workChange):
                var form = workChange.alteredForm
                let fieldAccessPath = FieldAccessPath.field(linkName: fieldLinkName)
        //get field value
                if  let (field,index) = form.getFieldAndIndex(using: fieldAccessPath),
                    case InputValues.mediaFieldValue(var fieldValue) = field.getValue() {
        //upload media
                    ZCFormAPIService.upload(media: media, withFileName: filename, for: fieldAccessPath, form: form) { (mediaResponse) in
                        switch mediaResponse {
                        case .sucess(let mediaResults):
        //set media field value
                            fieldValue.fileName = mediaResults.fileName
                            if let updatedField = field.setValueFor(value: .mediaFieldValue(fieldValue: fieldValue)) {
                                form.setField(updatedField, at: index)
            //submit the form
                                ZCFormAPIService.submit(form: form) { (submitResponse) in
                                    switch submitResponse {
                                    case .sucess(let successResponse):
                                        // Success Response
                                        print('Success')
                                    case .failure(_):
                                        //failure
                                        print('Failure')
                                    }
                                }
                            }
                        case .failure(let error):
                            print(error)
                        }
                    }
                }
            }
        }
    }


画像、ファイルアップロード、オーディオ、ビデオ、または署名フィールドにファイルをアップロードし、レコードを更新するためにフォームを提出するには:


func updateMediaField(media: Data,filename:String ,fieldLinkName: String,recordId: String,reportLinkName: String){
        let formInfo = FormInfo(linkName: '<formLinkName>', displayName: '<formDisplayName>', appLinkName: '<AppLinkName>', appOwner: '<AppOwner>', openUrlInfo: nil)
        ZCFormAPIService.fetch(forRecordID: recordId, reportLinkName: reportLinkName, formInfo: formInfo) { result in
            switch result {
            case .failure(let error):
                print(error)
            case .sucess(let workChange):
                var form = workChange.alteredForm
                let fieldAccessPath = FieldAccessPath.field(linkName: fieldLinkName)
                if  let (field,index) = form.getFieldAndIndex(using: fieldAccessPath),
                    case InputValues.mediaFieldValue(var fieldValue) = field.getValue() {
        //upload the media
                    ZCFormAPIService.upload(media: media, withFileName: filename, for: fieldAccessPath, form: form) { (mediaResponse) in
                        switch mediaResponse {
                        case .sucess(let mediaResults):
        // set media field value
                            fieldValue.fileName = mediaResults.fileName
                            if let updatedField = field.setValueFor(value: .mediaFieldValue(fieldValue: fieldValue)) {
                                form.setField(updatedField, at: index)
            // update the record
                                ZCFormAPIService.updateRecord(withRecordID: recordId, inReportLinkName: reportLinkName, form: form) { (submitResponse) in
                                    switch submitResponse {
                                    case .sucess(let successResponse):
                                        // Success Response
                                        print('Success')
                                    case .failure(_):
                                        //failure
                                        print('Failure')
                                    }
                                }
                            }
                        case .failure(let error):
                            print(error)
                        }
                    }
                }
            }
        }
    }

 

Creatorアプリ内のセクションを取得する


let firstApp = self.appList.applications[0] ZCAPIService.fetchSectionList(for: firstApp, completionHandler: { (result) in
    switch result{
    case .failure(let error):
        // handle error
    case .sucess(let sectionList):        
        //handle sectionList
        self.sectionList = sectionList
}
})

 

レポートを取得する

let reportInfo = ReportInfo(openUrlInfo: nil, appOwner: '<app-owner>', appLinkName: '<app-link-name>', linkName: '<report-link-name>', type: .report, appDisplayname: nil, displayName: nil, notificationEnabled: false)
        let config = ListReportAPIConfiguration(fromIndex: 1, limit: 50, moreInfo: ReportAPIConfiguration.init())
        ZCReportAPIService.fetchListReport(for: reportInfo, with: config) { (result) in
            switch result{
            case .failure(let error):
                print(error)
            case .sucess(let listReport):
                //handle success
                print(listReport)
            }
        }

レポート内のレコードを処理する

ZCReportAPIService.fetchListReport(for: reportInfo, with: configuration) { (result) in
    
    switch result {
    case .success(let listReport):
        
        guard let firstRecord = listReport.records.first //Returns the first record. (You can also point to the desired record)
            else { return }
        
        do {
            let recordValue = try firstRecord.recordValue(for: '<Field Link Name of the desired Field>')
            
            //Returns the display string from the field you specified above
            let displayString = recordValue.value.displayValue(for: recordValue.column)
            
            
            //For further processing the received value
            switch  recordValue.value {
            case .text(let textValue): //For text value fields: single line, multi line, email, number, date, rich text, etc.
                textValue.value //Returns the string
                
            case .file(let fileValue): //For media fields: file upload, image, audio, video, signature
                fileValue.valueUrl //Returns the URL of the file
                fileValue.apiServiceProperties //Returns additional properties invloved with the field
                
            case .name(let nameValue): //For the name field
                nameValue.value //Returns the name field's display value
                nameValue.subValues //Returns subfield values from the name field: prefix, first_name, last_name, suffix
                
            case .address(let addressValue): //For the address field
                addressValue.value //Returns the address field's display vale
                addressValue.subValues //Returns subfield values from the address field: address_line_1, address_line_2, district_city, state_province, postal_Code, country
                addressValue.latitude //Returns the latitude, if available
                addressValue.longitude //Returns the longitude, if available
                
            case .phoneNumber(let phoneNumberValue): //For the phone field
                phoneNumberValue.value //Returns the phone number
                
            case .link(let linkValue): //For the link field
                linkValue.value //Returns the link field's display value
                linkValue.link //Returns the link corresponding to the field
                
            case .linkedRecords(let linkedRecordValues, delimiter: let delimiter): //For the lookup or subform field, where the Link to View property is configured
                let linkedRecord = linkedRecordValues.first //Returns the first record. (You can also point to the desired record)
                linkedRecord?.value //Returns the record's display string
                linkedRecord?.recordID //Returns the record's ID
                
            case .choices(let choiceValues, delimiter: let delimiter): //For the choice fields: radio, drop down, multi select, checkbox
                let choiceValue = choiceValues.first //Returns the first choice. (You can also point to the desired choice)
                choiceValue?.value //Returns the choice's string
                
            case .values(let values): //For the multi-select lookup field's related value
                //Here 'values' is an array which can be further processed as given above
                break
            }
            
        } catch let recordValueError {
            print('\(recordValueError) occurred while processing Record Value')
        }
        
    case .failure(let error):
        //Handle errors here
        print('Report Error Occurred: \(error)')
    }
 }

通知履歴を取得する


func fetchAllNotifications() {
 ZCAPIService.fetchUserInfo {(result) in
  switch (result)
   {
   case .success(let userInfo):
    ZCAPIService.fetchNotifications(forZUID: userInfo.zuid) { notificationsResult in
      switch(notificationsResult)
       {
       case .success(let notificationList):
        print ('\(notificationList)')
       case .failure(let error):
        print ('\(error)')
       }
    }
   case .failure(let error):
    print ('\(error)')
  }
 }
}

通知をタップしたときにレコードサマリーを表示する


func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
 if let notificationInfo = response.notification.request.content.userInfo as? [String: Any] {
  if ZCNotificationService.isCreatorServerNotification(notificationInfo: notificationInfo) == true {
   if let zcNotification = ZCNotificationService.zcNotification(notificationInfo)
   {
    let summaryVC = ZCUIService.getRecordSummaryViewController(for: zcNotification)
    window?.rootViewController?.present(UINavigationController.init(rootViewController: summaryVC), animated: true, completion: nil)
   }
  }
  else
  {
   // Not from Zoho Creator server
  }
  completionHandler()
 }
}

通知からレコードのメタデータを取得する


 func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
  if let notificationInfo = response.notification.request.content.userInfo as? [String: Any] {
   if ZCNotificationService.isCreatorServerNotification(notificationInfo: notificationInfo) == true {
    if let zcNotification = ZCNotificationService.zcNotification(notificationInfo) {
     ZCAPIService.fetchNotificationInfo(for: zcNotification) {(result) in
      switch (result)
       {
       case .success(let notificationRecordInfo):
        print ('\(notificationRecordInfo)')
       case .failure(let error):
        print ('\(error)')
      }
     }
    }
   }
   else
    {
    // Not from Zoho Creator server
    }
   completionHandler()
  }
 }


    Zoho CRM 管理者向けトレーニング

    「導入したばかりで基本操作や設定に不安がある」、「短期間で集中的に運用開始できる状態にしたい」、「運用を開始しているが再度学び直したい」 といった課題を抱えられているユーザーさまに向けた少人数制のオンライントレーニングです。

    日々の営業活動を効率的に管理し、導入効果を高めるための方法を学びましょう。

    Zoho CRM Training



              Zoho Desk Resources

              • Desk Community Learning Series


              • Digest


              • Functions


              • Meetups


              • Kbase


              • Resources


              • Glossary


              • Desk Marketplace


              • MVP Corner


              • Word of the Day









                                • Related Articles

                                • English: Sample Code SnippetsJapanese: サンプルコードスニペット

                                  お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。 注意:Zoho CreatorのモバイルSDKは現在ベータ版の機能です。製品段階でのアプリにおいて使用することはお勧めしません。 「 Java 」 以下は、Zoho CreatorのAndroid SDKのさまざまなメソッドを使用する方法を示すコードスニペットです。 ...
                                • 『iOS UIフレームワーク』

                                  お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。 このヘルプページはCreator 6のユーザー向けです。古いバージョン(Creator 5)の場合は、こちらをクリックしてください。Creatorのバージョンをご確認ください。 ...
                                • 「iOS コアフレームワーク」

                                  お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。 このヘルプページはCreator 6ユーザーのためのものです。古いバージョン(Creator 5)をお使いの場合は、こちらをクリックしてください。Creatorバージョンを確認することができます。 CreatorのiOS ...
                                • 「iOS UIフレームワーク」

                                  お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。 このヘルプページはCreator 6のユーザーのためのものです。古いバージョン(Creator 5)を使用している場合は、こちらをクリックしてください。Creatorバージョンをご確認ください。 ...
                                • {"error":{"code":null,"param":null,"message":"Your request contained invalid JSON: 'utf-8' codec can't decode byte 0xa0 in position 304: invalid start byte","type":"invalid_request_error"}}

                                  お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。 柱形図を設定する ...

                                Resources

                                Videos

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



                                eBooks

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



                                Webinars

                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                CRM Tips

                                Make the most of Zoho CRM with these useful tips.