メソッドと操作

メソッドと操作

ツールキットの詳細

クラス名: box.Toolkit

インスタンス変数

mostRecentError

String to indicate the most recent error that occurred when calling instance methods.

この文字列が存在しても、操作が失敗したことを意味するわけではありません。そのエラーが回復可能であった可能性もあります。ただし、この文字列に値がない場合は、操作が成功したことを示しています。

Enum CollaborationType

Enum to indicate the type of collaboration.

可能性のある値: EDITORVIEWERPREVIEWERUPLOADERCOOWNEROWNERPREVIEWERUPLOADERVIEWERUPLOADER

静的メソッド

deleteServiceUserAssociation

Method to clear association between Service Account and Box for Salesforce integration. This can be used to change the service account if an incorrect one is being used.

パラメータ:

  • なし

戻り値:

  • ユーザーのアカウントが存在していたが削除された場合はtrue
  • ユーザーのアカウントが何らかの理由(存在しなかった場合を含む)で削除されなかった場合はfalse

deleteUserAssociation

パラメータ説明
userIdid資格情報がクリアされるユーザーのID。

戻り値:

  • ユーザーのアカウントが存在していたが削除された場合はtrue
  • ユーザーのアカウントが何らかの理由(存在しなかった場合を含む)で削除されなかった場合はfalse

インスタンスメソッド(コンストラクタ/デストラクタ)

box.Toolkit()

パラメータ:

  • なし

commitChanges

Treat this method as a destructor for the box.Toolkit() method.

このメソッドは重要です。すべてのフォルダ/コラボレーション操作が完了した後、毎回、例外なくこのメソッドを呼び出す必要があります。

Salesforceではデータベースの更新/挿入/削除の後の呼び出しは許可されないため、Toolkitクラスではすべての呼び出し操作が完了した後で挿入するオブジェクトのコレクションが保持されます。このメソッドを呼び出さない場合、このようなオブジェクトがデータベースから消去され、ユーザー/レコード/フォルダの関連付けを追跡するテーブルの同期も失われて、高度なデバッグによる修正が必要になります。

パラメータ:

  • なし

戻り値:

  • Void

Generic Methods

Box for Salesforce Developer Toolkitは、パラメータとしてHttpRequestオブジェクトを受け取り、HttpResponseオブジェクトを返すグローバルメソッドを提供します。このメソッドではサービスアカウントの認証の詳細情報を利用してBoxのAPIを呼び出すため、開発者は統合のビジネスロジックに集中して取り組むことができます。

sendRequest

パラメータ説明
requestHttpRequestエンドポイントとメソッドが設定されたHttpRequestオブジェクト。

戻り値:

  • BoxのAPI呼び出しからの応答の詳細情報が含まれたHttpResponseオブジェクト。
  • HttpRequestのインプットの情報が不足している場合はToolkit.BoxApiException
  • サービスアカウントの認証の詳細情報を取得する際に問題が発生した場合はnull。この場合は、mostRecentErrorを確認してください。

ファイル操作

createFileFromAttachment

Available in version 3.46 and above.

Salesforceの文字列長の上限は600万文字です。base64エンコード/デコードプロセスでは文字列が膨張するため、有効なファイルサイズの上限は4.3MBとなっています。

パラメータ説明
attAttachmentThe attachment to be converted into a File in Box.
fileNameOverridestringOptional - Name of the new file. If no value is passed in, the name of the attachment is used.
folderIdOverridestringOptional - Box folder id to place this attachment in. If no value is passed in, the file will be placed in the folder associated with the record that is the parentId of the attachment. If the record-specific folder doesn't exist, it will be created.
accessTokenstringOptional - if accessToken is sent, that value is used for the Box API call. Otherwise, the default account credentials are used.

戻り値:

  • string。作成されたBoxファイルのIDが返されます。
  • エラーが発生した場合はnull。この場合には、mostRecentErrorを確認してください。

getObjectFolderByRecordId

パラメータ説明
recordIdidSalesforce record id whose root folder id you want to get.

戻り値:

  • string。レコードIDが渡されたオブジェクトルートフォルダのBoxフォルダIDが返されます。

フォルダ操作

getRootFolderId

パラメータ:

  • なし

戻り値:

  • string。SalesforceルートフォルダのBoxフォルダIDが返されます。

getObjectFolderByRecordId

パラメータ説明
recordIdidSalesforce record id whose root folder id you want to get.

戻り値:

  • string。レコードIDが渡されたオブジェクトルートフォルダのBoxフォルダIDが返されます。

getFolderUrl

  • This method gets the embed widget URL for a particular record so customers can use their own embed logic if desired.
  • このメソッドではシームレスなログインの設定が優先されます。このため、シームレスなログインが有効になっている場合、ユーザーはURLに自動的にログインされます。
パラメータ説明
recordIdidSalesforce record id whose root folder id you want to get.
isMobileContextbooleanBoolean to indicate whether the URL should be mobile (true) or not (false).

戻り値:

  • string。渡されたSalesforceレコードIDに関連付けられているフォルダを表すURLが返されます。このURLをBox埋め込みウィジェットで使用して、任意のVisualforceページに埋め込むことができます。

createObjectFolderForRecordId

パラメータ説明
recordIdidSalesforce record id whose root folder id you want to get.

戻り値:

  • string。作成されたルートフォルダのBoxフォルダIDが返されます。
  • ルートフォルダがすでに存在していた場合、そのルートフォルダのBoxフォルダIDが返されます。

createFolder

パラメータ説明
folderNamestringName of the folder to be created. Folder names are subject to some restrictions. See here for more details.
parentFolderIdstringParent Box folder this folder will be created in.
accessTokenstringOptional - If accessToken is sent, that value is used for the Box API call,; otherwise, the default service account credentials are used.

戻り値:

  • string。作成されたフォルダのBoxフォルダIDが返されます。
  • フォルダが作成されなかった場合はnullが返されます。この場合、mostRecentErrorで詳細を確認してください。

createFolderForRecordId

パラメータ説明
recordIdidSalesforce record id that a Box folder will be created for.
folderNameOverridestringBy default, the record's name will be the folder name. If you want to name it something else, send that value here.
optCreateRootFolderbooleanBoolean to indicate whether to create the object root folder if it doesn't exist. If false is sent and the root folder does not exist, the call will fail.

戻り値:

  • string。作成されたフォルダのBoxフォルダIDが返されます。
  • フォルダが作成されなかった場合はnullが返されます。この場合、mostRecentErrorで詳細を確認してください。
  • SalesforceレコードがすでにBoxフォルダに関連付けられている場合、既存のBoxフォルダIDが返されます。

moveFolder

パラメータ説明
folderIdstringBox folder Id of the folder to be moved.
newParentFolderIdstringBox folder Id of the folder that will be the new parent folder.
accessTokenstringOptional - If accessToken is sent, that value is used for the Box API call. Otherwise, the default service account credentials are used.

戻り値:

  • フォルダが正常に移動された場合はtrue
  • フォルダが正常に移動されなかった場合はfalsemostRecentErrorで詳細を確認してください。

フォルダ関連付けメソッド

getFolderAssociationsByRecordId

パラメータ説明
recordIdidSalesforce record id that the folder mapping entries returned are related to.

戻り値:

  • 返されるリストは、このレコードに関連付けられているすべてのフォルダマッピングエントリのコレクションです。
  • 一般に、フォルダマッピングエントリが存在しない場合は空のリストになりますが、状況によってnullになる場合があります。

getFolderIdByRecordId

パラメータ説明
recordIdidSalesforce record id whose folder id you wish to get.

戻り値:

  • string。渡されたSalesforceレコードIDに関連付けられたBoxフォルダIDが返されます。

getRecordIdByFolderId

パラメータ説明
folderIdstringBox folder id.

戻り値:

  • id。渡されたBoxフォルダIDに関連付けられたSalesforceレコードIDが返されます。

createFolderAssociation

パラメータ説明
recordIdidSalesforce record Id that is being associated with a box folder.
folderIdstringBox folder Id being associated with a Salesforce record.

戻り値:

  • boxFRUPcオブジェクト - エラーが発生した場合(mostRecentErrorを確認)、返されるFRUPオブジェクトはnullになります。このFRUPエントリは、commitChangesメソッドの呼び出し時にデータベースに挿入されます。このメソッドでは、同じフォルダの複数レコードへの関連付けやその逆の関連付けが許可されないため、他のフォルダの関連付けとの一貫性が保証されます。

コラボレーションメソッド

Box for Salesforce Developer Toolkitによって作成されたコラボレーションは、コラボレータにコラボレーションメールを送信しません。Box for Salesforce統合に使用されるサービスアカウントのみがコラボレーションメールを受け取ります。

createCollaboration

パラメータ説明
folderIdstringBox folder id to create a collaboration on.
boxUserIdstringBox user id to be collaborated (either boxUserId or emailAddress is required but not both).
emailAddressbox.Toolkit.CollaborationTypeEmail address of the box user to be.
collabTypestringType of collaboration (see the CollaborationType enum definition).
accessTokenstringOptional - If sent, this value is used for authentication for the box API call; if null, the service account credentials are used.

戻り値:

  • string。作成されたBoxコラボレーションのIDが返されます。
  • エラーが発生した場合はnullが返されます。その場合、mostRecentErrorを確認してください。

createCollaborationOnRecord

パラメータ説明
userIdidSalesforce user id to be collaborated.
recordIdidSalesforce record id of the record folder to be collaborated on.
collabTypebox.Toolkit.CollaborationTypeType of collaboration (see the CollaborationType enum definition).
optCreateFolderbooleanBoolean to indicate whether to create the Box folder associated for the Salesforce record id if it does not already exist. This also creates the root folder if it did not already exist. If set to false and the folder does not already exist, the call will fail.

戻り値:

  • string。作成されたBoxコラボレーションのIDが返されます。
  • エラーが発生した場合はnullが返されます。その場合、mostRecentErrorを確認してください。