Box: Cancel Sign Request

Box: Cancel Sign Request

Box Sign: 署名リクエストキャンセル

This item cancels the specified sign request on Box.

Basic Configs
Step Name
Note
Auto Step icon
Configs for this Auto Step
conf_OAuth2
C1: OAuth2 Setting *
conf_RequestId
C2: Sign Request ID *

Notes

  • Box Sign must be enabled on the Box platform (default: disabled)
  • Users authenticating in the C1: OAuth2 Setting must have a Box Business plan user account
  • The ID of the sign request to set in the C2: Sign Request ID can be retrieved using Box Sign: Create Sign Request
    • It is different from the ID shown in the WebUI of Box Sign
  • It will complete successfully even if it cannot be canceled due to the status
    • Signed, Canceled, Declined, Converting, etc

Capture

See Also

Script (click to open)
  • An XML file that contains the code below is available to download
    • box-sign-request-cancel.xml (C) Questetra, Inc. (MIT License)
    • If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step

function main() {
    const oauth2 = configs.getObject("conf_OAuth2");
    const requestId = decideRequestId();
    cancelRequest(oauth2, requestId);
}

/**
 * リクエストIDをconfigから読み出して出力する。
 * @return {String} requestId リクエスト ID
 */
function decideRequestId() {
    const requestIdDef = configs.getObject("conf_RequestId");
    requestId = engine.findData(requestIdDef);
    if (requestId === null) {
        throw "Request ID is blank";
    }
    return requestId;
}

/**
 * 署名リクエストキャンセル
 * 全員署名済、拒否、キャンセル済、変換中等、ステータスが原因でキャンセルに失敗する場合は正常終了
 * ステータス以外が原因でキャンセルに失敗する場合はエラーにする
 * @param {AuthSettingWrapper} oauth OAuth2 設定
 * @param {String} requestId 署名リクエストの ID
 */
function cancelRequest(oauth2, requestId) {
    const url = `https://api.box.com/2.0/sign_requests/${requestId}/cancel`;
    const response = httpClient.begin()
        .authSetting(oauth2)
        .post(url);
    const status = response.getStatusCode();
    const responseTxt = response.getResponseAsString();

    if (status === 200) {
        engine.log(`status: ${status} Request was cancelled, request ID: ${requestId}`);
        return;
    } else if (status === 400) {
        engine.log(responseTxt);
        engine.log('The status can be "Signed", "Canceled", "Declined", or "Converting".');
        return;
    } else {
        const error = `Failed to cancel. status: ${status}`;
        engine.log(responseTxt);
        throw error;
    }
}

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading