2016-09-20 14 views
1

DocuSign NodeJS SDKを使用して、DocuSignコンソールから既に設定したテンプレートから署名リクエストを作成しています。私はまた、文書にテキストフィールドを設定しました。署名リクエストを送信すると、このフィールドに自動的に値を設定したいと思います。ここでNodeJs SDKを使用してDocuSignエンベロープ定義にタブを設定する

は(そのほとんどがちょうどレシピからコピーされた)私のコードの関連する部分である:

var envDef = new docusign.EnvelopeDefinition(); 
envDef.setEmailSubject('Ready for Signing'); 
envDef.setTemplateId(templateId); 

    // create a template role with a valid templateId and roleName and assign signer info 
var tRole = new docusign.TemplateRole(); 
tRole.setRoleName("Role1"); 
tRole.setName(role1FullName); 
tRole.setEmail(role1Email); 
tRole.setClientUserId(role1UserId); 

/**************SET TABS******************/ 
//set tabs 
var text = new docusign.Text(); 
text.setTabLabel("textFoo"); //This is the data label I setup from the console. 
text.setValue("Foo Bar Zoo"); //Some text I want to have pre-populated 

var textTabs = []; 
textTabs.push(text); 

var tabs = new docusign.Tabs(); 
tabs.setTextTabs(textTabs); 

tRole.setTabs(tabs); 
/**************END SET TAB******************/ 

// create a list of template roles and add our newly created role 
var templateRolesList = []; 
templateRolesList.push(tRole); 

// assign template role(s) to the envelope 
envDef.setTemplateRoles(templateRolesList); 



// send the envelope by setting |status| to 'sent'. To save as a draft set to 'created' 
envDef.setStatus('sent'); 

私はこれを実行すると、私は次のエラーを取得:

Bad Request 
    at Request.callback (C:\Users\janak\NodeProjects\DocuFire\node_modules\superagent\lib\node\index.js:823:17) 
    at IncomingMessage.<anonymous> (C:\Users\janak\NodeProjects\DocuFire\node_modules\superagent\lib\node\index.js:1046:12) 
    at emitNone (events.js:91:20) 
    at IncomingMessage.emit (events.js:185:7) 
    at endReadableNT (_stream_readable.js:975:12) 
    at _combinedTickCallback (internal/process/next_tick.js:74:11) 
    at process._tickCallback (internal/process/next_tick.js:98:9) 

注意を:SET TABSの部分をコメントアウトすると、このコードは正常に実行され、署名URLを取得してそこでユーザーをリダイレクトできます。

私は間違っていますか?

このStackOverflow postは、XML APIの何らかの形式でリクエストするときにこの疑問に答えるようです。しかし、これをNodeJs SDKを使ってどうすればいいですか?

答えて

0

私のコードは正しいと思われますが、SDKにはバグがあります:Unable to send tabs #50

ソリューション:

I was correctly constructing the request -- but the node client populates all empty model parameters with null

Recursively stripping the nulls from the envelope before submitting the request solved this issue for me:

removeNulls = function(envelope) { 
    var isArray = envelope instanceof Array; 
    for (var k in envelope) { 
     if (envelope[k] === null) isArray ? obj.splice(k, 1) : delete envelope[k]; 
     else if (typeof envelope[k] == "object") removeNulls(envelope[k]); 
     if (isArray && envelope.length == k) removeNulls(envelope); 
    } 
    return envelope; 
} 

Reference

私はそうのように、この機能を使用:

tRole.setTabs(removeNulls(tabs)); 
関連する問題