FieldAccessPath を使用すると、対象のフィールドを、対象のフォーム内で参照できます。構築方法は次のように異なります。
通常のフィールドの場合:
FieldAccessPath.項目(linkName: <FieldLinkName>)
複合フィールド内のサブフィールドの場合(例: 名前フィールド内の first_name フィールド、または住所フィールド内の 国 フィールドなど):
FieldAccessPath.compositeField(linkName: <CompositeFieldLinkName>, subFieldLinkName: <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
切り替える workFlowChangeSetResult {
case .完了(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(_):
// 失敗
}
}
Zoho Creator では、次のフィールドタイプで選択肢が表示されます:ドロップダウン、ラジオボタン、複数選択、チェックボックス、ルックアップ、「氏名」フィールドの「敬称」サブフィールド、「住所」フィールドの「国」サブフィールドです。必須フィールドの AccessPath を構成するには、このセクションを参照してください。フォームでデータを追加する際に、フィールドに表示される選択肢を取得するには:
// FieldAccessPath の構築方法については参照してください
let fieldAccessPath = FieldAccess.項目(linkName: <ChoiceFieldLinkName>)
ZCFormAPIService.fetchChoices(forSearchString: <SearchString>, of: fieldAccessPath, in: <form>, fromIndex: <FromIndex>) { (result) in
切り替える result {
case .完了(let choices):
// 選択肢
case .failure(_):
// 失敗
}
}
フォームでレコードを編集する際に、フィールドに表示される選択肢を取得するには:
let fieldAccessPath = FieldAccess.項目(linkName: <ChoiceFieldLinkName>)
ZCFormAPIService.fetchChoices(withRecordID: <データ Id>, forReportLinkName: <ReportLinkName>, forSearchString: <検索する String>, of: fieldAccessPath, in: <form>, fromIndex: <FromInde>) { (result) in
切り替える result {
case .完了(let choices):
//choices
case .failure(_):
//failure
}
}
フォームを送信してデータを追加するには:
ZCFormAPIService.送信する(form: <Form>) { (result) in
切り替える result {
case .完了(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):
// 応答を送信
case .failure(let error):
// エラー
}
}
<form>.getFieldAndIndex(using: <fieldAccessPath>)
// (field, index)
<field>.getValue()
// InputValues
InputValues.textFieldValue(fieldValue: “<your_input>”)
InputValues.decisionFieldValue(fieldValue: <boolean_value>)
if case InputValues.singleSelectChoiceFieldValue(var existingValue) = <field>.getValue() {
existingValue.selectedChoice = { existingValue.choice から適切な値を選択します }
let newField = field.setValueFor(value: existingValue) //更新された項目
}
if case InputValues.multiSelectChoiceFieldValue(var existingValue) = <field>.getValue() {
existingValue.selectedChoice = { existingValue.choice から適切な値を選択します }
let newField = field.setValueFor(value: existingValue) //更新された項目
}
let newField = field.setValueFor(value: InputValues.phoneNumberFieldValue(countryCode:<コード>,number: <PhoneNumber>))
let newField = field.setValueFor(value: InputValues.urlFieldValue(url:<url>,title:<title>,linkName:<linkName>))
<form>.setField(updatedField,at: index)
画像、ファイルアップロード、audio、video、または署名項目にファイルをアップロードし、フォームを送信してデータを追加するには:
funcsubmitMediaField(:Data,:String,:String){let=FormInfo(:'<formLinkName>',:'<formDisplayName>',:'<AppLinkName>',:'<AppOwner>',:nil)// フォームを取得ZCFormAPIService.fetch(for:(){in切り替える{case.failure(let):印刷する()case.sucess(let):var=.let=FieldAccessPath.項目(:)//get 項目 値iflet(,)=.getFieldAndIndex(:),caseInputValues.mediaFieldValue(var)=.getValue(){// メディアをアップロードZCFormAPIService.アップロードする(:,:,for:,:){()in切り替える{case.sucess(let):// メディア項目の値を設定.=.iflet=.setValueFor(:.mediaFieldValue(:)){.setField(,:)// フォームを送信ZCFormAPIService.送信する(:){()in切り替える{case.sucess(let):// 完了レスポンス印刷する('完了')case.failure(_):// 失敗印刷する('Failure')}}}case.failure(let):印刷する()}}}}}}
画像、ファイルアップロード、オーディオ、ビデオ、または署名項目にファイルをアップロードし、そのフォームを送信してデータを更新するには、次のようにします。
funcupdateMediaField(:Data,:String,:String,:String){let=FormInfo(:'<formLinkName>',:'<formDisplayName>',:'<AppLinkName>',:'<AppOwner>',:nil)ZCFormAPIService.fetch(:,:,:){in切り替える{case.failure(let):印刷する()case.sucess(let):var=.let=FieldAccessPath.項目(:)iflet(,)=.getFieldAndIndex(:),caseInputValues.mediaFieldValue(var)=.getValue(){// メディアをアップロードするZCFormAPIService.アップロードする(:,:,for:,:){()in切り替える{case.sucess(let):// メディア項目の値を設定.=.iflet=.setValueFor(:.mediaFieldValue(:)){.setField(,:)// データを更新するZCFormAPIService.updateRecord(:,:,:){()in切り替える{case.sucess(let):// 完了レスポンス印刷する('完了')case.failure(_):// 失敗印刷する('Failure')}}}case.failure(let):印刷する()}}}}}}
let firstApp = self.appList.applications[0] ZCAPIService.fetchSectionList(for: firstApp, completionHandler: { (result) in
switch result{
case .failure(let error):
// エラーを処理
case .sucess(let sectionList):
// sectionList を処理
self.sectionList = sectionList
}
})
let reportInfo = ReportInfo(openUrlInfo: nil, appOwner: '<アプリ所有者>', appLinkName: '<アプリリンク名>', linkName: '<レポートリンク名>', 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):
// 完了を処理
print(listReport)
}
}
ZCReportAPIService.fetchListReport(for:,:){()inswitch{case.完了(let):guardlet=..first// 最初のデータを返します。(必要に応じて目的のデータを指定することもできます)else{return}do{let=try.recordValue(for:'<目的のフィールドのフィールドリンク名>')//上で指定したフィールドの表示文字列を返しますlet=..displayValue(for:.)//取得した値をさらに処理する場合切り替える.{case.text(let)://テキスト値フィールド用:単一行、複数行、メール、数値、日付、リッチテキストなど.//文字列を返しますcase.file(let)://メディアフィールド用:ファイルアップロード、画像、音声、動画、署名.//ファイルのURLを返します.//フィールドに関連する追加プロパティを返しますcase.名前(let)://名前フィールド用.//名前フィールドの表示値を返します.//名前フィールドのサブフィールド値(敬称、first_name、last_name、敬称(後置))を返しますcase.住所(let)://住所フィールド用.//住所フィールドの表示値を返します.//住所フィールドのサブフィールド値(address_line_1、address_line_2、district_city、state_province、postal_Code、国)を返します.//利用可能な場合は緯度を返します.//利用可能な場合は経度を返しますcase.phoneNumber(let)://電話番号フィールド用.//電話番号を返しますcase.リンク(let)://リンクフィールド用.//リンクフィールドの表示値を返します.//フィールドに対応するリンクを返しますcase.linkedRecords(let,:let)://[表示するリンク]プロパティが設定されているルックアップまたはサブフォームフィールド用let=.first//最初のレコードを返します(任意のレコードを指定することもできます)?.//レコードの表示文字列を返します?.//レコードのIDを返しますcase.choices(let,:let)://選択フィールド用:ラジオボタン、ドロップダウン、複数選択、チェックボックスlet=.first//最初の選択肢を返します(任意の選択肢を指定することもできます)? .//選択肢の文字列を返しますcase.values(let)://複数選択ルックアップ項目の関連値//ここで 'values' は配列であり、上記のようにさらに処理できますbreak}}catchlet{印刷する('\(recordValueError) データ値の処理中に発生しました')}case.failure(let)://ここでエラーを処理します印刷する('レポートエラーが発生しました: \(エラー)')}}
func fetchAllNotifications() {
ZCAPIService.fetchUserInfo {(result) in
切り替える (result)
{
case .完了(let userInfo):
ZCAPIService.fetchNewNotifications(lastNotificationID: nil, filterUnread: false, filteredApp: nil) { notificationsResult in
切り替える(notificationsResult)
{
case .完了(let notificationList):
印刷する ('\(notificationList)')
case .failure(let error):
印刷する ('\(エラー)')
}
}
case .failure(let error):
印刷する ('\(エラー)')
}
}
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> 無効) {
if let notificationInfo = response.notification.request.content.userInfo as? [String: Any] {
if ZCNotificationService.isCreatorServerNotification(notificationInfo: notificationInfo) == 真 {
if let zcNotification = ZCNotificationService.zcNotification(notificationInfo)
{
let summaryVC = ZCUIService.getNotificationController(for: zcNotification)
window?.rootViewController?.present(UINavigationController.init(rootViewController: summaryVC), animated: 真, completion: nil)
}
}
else
{
// Zoho Creator サーバーからの通知ではありません
}
completionHandler()
}
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> 無効) {
if let notificationInfo = response.notification.request.content.userInfo as? [String: Any] {
if ZCNotificationService.isCreatorServerNotification(notificationInfo: notificationInfo) == 真 {
if let zcNotification = ZCNotificationService.zcNotification(notificationInfo) {
ZCAPIService.fetchNewNotificationRedirectionInfo(notificationID: zcNotification.notificationID, category: zcNotification.category) { result in
切り替える (result)
{
case .完了(let notificationRecordInfo):
印刷する ('\(notificationRecordInfo)')
case .failure(let error):
印刷する ('\(エラー)')
}
}
}
}
else
{
// Zoho Creator サーバーからのものではありません
}
completionHandler()
}
}
「導入したばかりで基本操作や設定に不安がある」、「短期間で集中的に運用開始できる状態にしたい」、「運用を開始しているが再度学び直したい」 といった課題を抱えられているユーザーさまに向けた少人数制のオンライントレーニングです。
日々の営業活動を効率的に管理し、導入効果を高めるための方法を学びましょう。