ishant.kesar

How to create Transaction from Template using Apex SDK

0 votes

I am trying to create one span transaction with package using Apex SDK. But I am receiving this error. I have a placeholder role as "Placeholder1" which I am replacing with a signer in the transaction. When I send the package to One Span it doesn't replace the package but however create a new role with signer. Please help

 

Below is the code:

            OneSpanSDK sdk = new OneSpanSDK();
            OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x();
            pkg.name = 'TEST';
            pkg.description = 'TEST';
            String placeholder1Id = 'Signer1';
            OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role();
            OneSpanAPIObjects.Signer signer1 = new OneSpanAPIObjects.Signer();
            signer1.firstName = 'Mr.';
            signer1.lastName = 'Bean';
            signer1.email = '[email protected]';
            signer1.id = placeholder1Id;
            role1.signers = new List<OneSpanAPIObjects.Signer>{signer1};
                role1.id = placeholder1Id;
            pkg.roles = new List<OneSpanAPIObjects.Role>{role1};
                pkg = sdk.helper.createPackageFromTemplate(pkg, packageId);
            OneSpanAPIObjects.Package_x pack = sdk.getPackage(pkg.id);
            pack.status = OneSpanAPIObjects.PackageStatus.SENT;
            sdk.updatePackage(pack, pack.id);

 

 


 


Reply to: How to create Transaction from Template using Apex SDK

0 votes

Hi ishant.kesar,

 

Did you create the template and the placeholder via UI? In that case, the actual placeholder ID might not be "Placeholder1" as labeled in UI ("Placeholder1" is just the role name). Could you share the template ID so that I can have a quick check for you?

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: How to create Transaction from Template using Apex SDK

0 votes

Hi Duo,

 

Yes, I have created the template from the eSignLive UI. And I have checked the ID is different but howcan I replace the placeholder with real signer?


Reply to: How to create Transaction from Template using Apex SDK

0 votes

Hi ishant.kesar,

 

Thanks for the clarification!

With a quick workaround, you can use the actual role ID (in format of UUID, e.g. "61626d6e-18c1-4824-9681-190c0fb76dbd") in stead of role name "Placeholder1".

As you may have noticed, this inconsistence (role ID vs name) is caused because the placeholder was created from UI. You can delete and re-add the placeholder via this API with payload similar to below, in which case you don't need to adjust the APEX code:

POST /api/packages/{templateId}/roles

{
  "id": "Placeholder1",
  "type": "SIGNER",
  "name": "Placeholder1"
}

 

Duo

 

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: How to create Transaction from Template using Apex SDK

0 votes

Hi Duo,

I cannot use the POST request, but I need to replace the placeholder with actual signer because the template document has placeholder for the signature and those will be remove.

What should be ideal option for this solution.

 

Thank you in advance.


Reply to: How to create Transaction from Template using Apex SDK

0 votes

Hi ishant.kesar,

 

Did you encounter any problem using the POST call, or you meant you can't modify the template? As I mentioned, the quickest workaround is to use the actual placeholder ID in code instead of "Signer1"/"Placeholder1".

            String placeholder1Id = '61626d6e-18c1-4824-9681-190c0fb76dbd';

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off