API to Get Custom Tabs
If you want to update the information about the signer in records after the recipient signs and sends the agreement across, use the getCustomTabs APIs. getTabs for each Recipient: Enables you to retrieve the values set within input tags for a field in the contract when the request for eSignature is completed.
We have customized the code as per Use Case 2. You can customize the code as per your business requirements.
The snippet below enables you to fetch and update the information of a signer:
/*
* Sample class for demonstrating how to get the values from DocuSign custom tags
* and update the custom fields on DocuSign Default Recipient object on an Apttus Agreement
*/
global class DocuSignEnvelopeGetRecipientTabs2Imp implements Apttus_DocuApi.IDocuSignEnvelopeGetRecipientTabs2{
global DocuSignEnvelopeGetRecipientTabs2Imp(){
}
global void getRecipientTabs(List<Apttus_DocuApi.GetRecipientTabsWrapper> iListGetRecipientTabsWrapper){
Set<ID> setParentId = new Set<ID>();
for(Apttus_DocuApi.GetRecipientTabsWrapper objGetRecipientTabsWrapper : iListGetRecipientTabsWrapper){
try{
ID parentId = ID.valueOf(objGetRecipientTabsWrapper.parentId);
if(!setParentId.contains(parentId)){
setParentId.add(parentId);
}
}catch(Exception ex){
System.debug('ERROR : it is DEMO...!');
}
}
List <Apttus_DocuApi__DocuSignDefaultRecipient2__c> listRecipients = [SELECT Apttus_CMDSign__AgreementId__c,Apttus_DocuApi__ReadOnlyEmail__c,Apttus_DocuApi__SigningOrder__c,CustomTab1__c,CustomTab2__c,CustomTab3__c from Apttus_DocuApi__DocuSignDefaultRecipient2__c where Apttus_CMDSign__AgreementId__c in :setParentId];
Map <String,Apttus_DocuApi__DocuSignDefaultRecipient2__c> recipientMap = new Map <String,Apttus_DocuApi__DocuSignDefaultRecipient2__c>();
for(Apttus_DocuApi__DocuSignDefaultRecipient2__c r : listRecipients){
String strKey = r.Apttus_CMDSign__AgreementId__c + String.valueOf(r.Apttus_DocuApi__SigningOrder__c);
recipientMap.put(strKey,r);
}
List<Apttus_DocuApi__DocuSignDefaultRecipient2__c> toUpdate = new List<Apttus_DocuApi__DocuSignDefaultRecipient2__c>();
for(Apttus_DocuApi.GetRecipientTabsWrapper objGetRecipientTabsWrapper : iListGetRecipientTabsWrapper){
try{
ID parentId = ID.valueOf(objGetRecipientTabsWrapper.parentId);
System.debug(System.LoggingLevel.ERROR, 'Parent Id == > '+parentId);
Apttus_DocuApi__DocuSignDefaultRecipient2__c docuSignDefaultRecipient = null;
System.debug(System.LoggingLevel.ERROR, 'Step 001 == >');
Apttus_DocuApi.DocuSignUtil2.DocuSignRecipientStatus objRecipeintStatus = objGetRecipientTabsWrapper.recipientStatus;
System.debug(System.LoggingLevel.ERROR, 'Step 001.1 == >');
String strKey = parentId + objRecipeintStatus.routingOrder;
Apttus_DocuApi.DocuSignUtil2.RecipientTabs rTabs = objRecipeintStatus.tabs;
//check if the recipient tab has text tabs
System.debug('Map values == > '+JSON.serialize(recipientMap));
if(recipientMap.containsKey(strKey)){
System.debug('Getting Map values for Id == > '+strKey);
docuSignDefaultRecipient = recipientMap.get(strKey);
}
if(rTabs.textTabs.size() > 0){
//populate the first custom field with the data in the first text tab
Apttus_DocuApi.DocuSignUtil2.textTab tTab = rTabs.textTabs[0];
docuSignDefaultRecipient.CustomTab1__c = String.ValueOf(tTab.value);
//populate the second custom field with the data in the second text tab
Apttus_DocuApi.DocuSignUtil2.textTab tTab1 = rTabs.textTabs[1];
docuSignDefaultRecipient.CustomTab2__c = String.ValueOf(tTab1.value);
}
//check if the recipient tab has email tabs
if(rTabs.emailTabs.size() > 0){
//populate the third custom field with the data in the first email tab
Apttus_DocuApi.DocuSignUtil2.emailTab eTab = rTabs.emailTabs[0];
docuSignDefaultRecipient.CustomTab3__c = String.ValueOf(eTab.value);
}
toUpdate.add(docuSignDefaultRecipient);
} catch(Exception ex){
System.debug('ERROR AT the :'+ex.getMessage());
}
} // for
if(toUpdate.size() > 0){
update toUpdate;
System.debug('ERROR: UPDATE DocuSignDefaultRecipient: '+toUpdate.size());
} else{
System.debug('ERROR: UPDATE DocuSignDefaultRecipient: '+toUpdate.size());
}
}
}
