How to apply template setAnchorXOffset when you create an envelope from a template?

53 views Asked by At

I used the docusign-design-java-2.15.0 SDK.

I made a template and used SETANCHOR API. And when I made an envelope with template, setAnchorXOffset or setAnchorYOffset were not applied.

create template code

public Map<String,Object> createTemplate(Map<String,Object> tempInfo, Map<String,Object> buyerInfo, List<Map<String,Object>> supplierList, List<DocumentMgt> documentMgtList){
    Map<String,Object> result = new HashMap<String,Object>();
    TemplatesApi templatesApi = new TemplatesApi();
    EnvelopeTemplate envelopeTemplate = new EnvelopeTemplate();
    String templateName = (String)tempInfo.get("template_name");
    result.put(Const.RESULT_STATUS, Const.SUCCESS);
    int supplierSignOrder = 0;
    try {
        List<Signer> signerList = new ArrayList<Signer>();
        
        Signer bpSigner = new Signer();
        
        String bpRecipientId = UUID.randomUUID().toString();
        String bpClientUserId = UUID.randomUUID().toString();
        
        String bpAnchorString = (String)tempInfo.get("bp_sign_anchor_name");
        String bpSignDocumentId = (String)tempInfo.get("bp_sign_document_id");
        String bpEmail = (String)tempInfo.get("bp_email");

        SignHere signHere = makeSignHere(bpAnchorString, bpSignDocumentId, bpRecipientId);
        List<SignHere> signHereTabs = new ArrayList<SignHere>();
        signHereTabs.add(signHere);
        ....
        ......
}

anchor function

public SignHere makeSignHere(String anchorString, String documentId, String recipientId) {
    SignHere signHere = new SignHere();
    signHere.setDocumentId(documentId);
    signHere.setRecipientId(recipientId);
    signHere.setAnchorString(anchorString);
    signHere.setScaleValue("170");
    signHere.setAnchorXOffset("-100");
    signHere.setAnchorYOffset("-10");
    
    return signHere;
}

create envelope code

public Map<String,Object> createEnvelope(Map<String,Object> templateInfo){
    Map<String,Object> result = new HashMap<String,Object>();
    result.put(Const.RESULT_STATUS, Const.SUCCESS);
    
    EnvelopeDefinition envDef = new EnvelopeDefinition();
    String templateId = (String)templateInfo.get("template_id");
    envDef.setTemplateId(templateId);
    String emailSubject = (String)templateInfo.get("title");
    envDef.setEmailSubject(emailSubject);
    EnvelopesApi envelopesApi = new EnvelopesApi();
    EnvelopeSummary envelopeSummary;
    
    String docusignstatus = (String)templateInfo.get("docusign_status");
    envDef.setStatus(docusignstatus);
            
    try {
        envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
    } catch (ApiException e) {
        LOG.error("ERROR : " + e.toString());
    }
    
    return result;
}
1

There are 1 answers

0
Nima On

Without seeing your doc, it's difficult to debug the issue you're seeing. One way you can debug this further is to use postman and use the following JSON to try and see if you can get them to work:

Endpoint: https://demo.docusign.net/restapi/v2.1/accounts/xxxx/envelopes

{
    {
        "document": {
            "documentBase64": ".........", << provide your document here
            "documentId": "1",
            "name": "Letter"
        },
        "inlineTemplates": [
            {
                "recipients": {
                    "signers": [
                        {
                            "email": "[email protected]",
                            "name": "Random Tester2",
                            "recipientId": "1",
                            "tabs": {
                                "signHereTabs": [
                                    {
                                        "anchorString": "November",
                                        "anchorUnits": "pixels",
                                        "anchorXOffset": "20",
                                        "anchorYOffset": "10"
                                    }
                                ]
                            }
                        }
                    ]
                },
                "sequence": "4"
            }
        ]
    }
],
"emailSubject": "Test",
"expireAfter": "2",
"expireEnabled": "true",
"status": "sent"

}

See if you can apply the offsets that way. That should provide some clarification as to what might be going wrong.