DocuSign does not pass values to Salesforce - api

DocuSign doesn't pass values back into Salesforce. And Even doesn't give me any errors in the logs.
I used a Custom Field like source ID and MergeFieldXml tab option with the write-back = true. But it doesn't work.
Please advise what is wrong?
Merge fields are enabled for the DocuSign account.
My code example:
global class AnnualContract
{
webService static string AM_SendToDocuSign(String id, string strObjType)
{
Docusign_API_Setting__c APISetting = Docusign_API_Setting__c.getInstance('API Settings');
String envelopeId = '';
string DealerName = '';
string DealerId = '';
String accountId = APISetting.AccountId__c;
String userId = APISetting.UserId__c;
String password = APISetting.Password__c;
String integratorsKey = APISetting.IntegratorsKey__c;
String webServiceUrl = APISetting.WebServiceUrl__c;
list<Lead> lstLead = new list<Lead>();
list<Contact> lstContact = new list<Contact>();
if(strObjType == 'Lead')
{
lstLead = [SELECT Name,Status,Email,FirstName,LastName,Owner.Name,Title,FROM Lead where id = : Id limit 1];
}
StaticResource objSR = [SELECT Id,name, SystemModStamp FROM StaticResource WHERE Name = 'AnnualContractPDF' LIMIT 1];
String url_file_ref = '/resource/' + String.valueOf(((DateTime)objSR.get('SystemModStamp')).getTime())+ '/' + objSR.get('Name');
if(strObjType == 'Lead')
{
DealerName = lstLead[0].Name;
}
DocuSignAPI.APIServiceSoap dsApiSend = new DocuSignAPI.APIServiceSoap();
dsApiSend.endpoint_x = webServiceUrl;
//Set Authentication
String auth = '<DocuSignCredentials><Username>'+ userId
+'</Username><Password>' + password
+ '</Password><IntegratorKey>' + integratorsKey
+ '</IntegratorKey></DocuSignCredentials>';
System.debug('Setting authentication to: ' + auth);
dsApiSend.inputHttpHeaders_x = new Map<String, String>();
dsApiSend.inputHttpHeaders_x.put('X-DocuSign-Authentication',
auth);
DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope();
envelope.Subject = 'Please Sign this Contract' + lstLead[0].Name;
envelope.EmailBlurb = 'This is my new eSignature service, it allows me to get your signoff without having to fax, scan, retype, refile and wait forever';
envelope.AccountId = accountId;
// Render the contract
System.debug('Rendering the contract');
PageReference pageRef = new PageReference(url_file_ref);
Blob pdfBlob = pageRef.getContent();
DocuSignAPI.CustomField field = new DocuSignAPI.CustomField ();
field.Name = '##SFLead';
field.Value = lstLead[0].Id; //value of the external source Id
field.Show = 'false';
field.CustomFieldType = 'Text';
envelope.CustomFields = new DocuSignAPI.ArrayOfCustomField();
envelope.CustomFields.CustomField = new DocuSignAPI.CustomField[1];
envelope.CustomFields.CustomField[0] = field;
// Document
DocuSignAPI.Document document = new DocuSignAPI.Document();
document.ID = 1;
document.pdfBytes = EncodingUtil.base64Encode(pdfBlob);
document.Name = 'Annual Contract';
document.FileExtension = 'pdf';
envelope.Documents = new DocuSignAPI.ArrayOfDocument();
envelope.Documents.Document = new DocuSignAPI.Document[1];
envelope.Documents.Document[0] = document;
// Recipient
System.debug('Building up the recipient');
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipient.Email = lstLead[0].Email;
recipient.UserName = lstLead[0].FirstName + ' ' + lstLead[0].LastName;
recipient.RequireIDLookup = false;
envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
envelope.Recipients.Recipient[0] = recipient;
// Tab
DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab();
tab1.Type_x = 'SignHere';
tab1.RecipientID = 1;
tab1.DocumentID = 1;
tab1.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab1.AnchorTabItem.AnchorTabString = '/t1/';
tab1.AnchorTabItem.XOffset = 100;
DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab();
tab2.Type_x = 'DateSigned';
tab2.RecipientID = 1;
tab2.DocumentID = 1;
tab2.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab2.AnchorTabItem.AnchorTabString = '/d1/';
DocuSignAPI.Tab tab3 = new DocuSignAPI.Tab();
tab3.CustomTabType = 'Text';
tab3.Name = 'Title';
tab3.Type_x = 'Custom';
tab3.RecipientID = 1;
tab3.DocumentID = 1;
tab3.TabLabel = 'Title';
if(strObjType == 'Lead')
{
if(lstLead[0].Title != null)
{
tab3.Value = ''+lstLead[0].Title+'';
}
}
else
{
if(lstContact[0].Title != null)
{
tab3.Value = ''+lstContact[0].Title+'';
}
}
tab3.CustomTabWidth=100;
tab3.CustomTabRequired=false;
tab3.CustomTabLocked=false;
tab3.CustomTabDisableAutoSize=false;
tab3.TemplateLocked=false;
tab3.TemplateRequired=false;
tab3.ConditionalParentLabel='';
tab3.ConditionalParentValue='';
tab3.SharedTab=true;
tab3.RequireInitialOnSharedTabChange=false;
tab3.ConcealValueOnDocument=false;
tab3.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab3.AnchorTabItem.AnchorTabString = '/t2/';
tab3.AnchorTabItem.XOffset = 42;
tab3.AnchorTabItem.YOffset = -5;
tab3.MergeFieldXml = '<mergeField><allowSenderToEdit>true</allowSenderToEdit><configurationType>salesforce</configurationType><path>Lead.Title</path><row>1</row><writeBack>true</writeBack></mergeField>';
envelope.Tabs = new DocuSignAPI.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignAPI.Tab[3];
envelope.Tabs.Tab[0] = tab1;
envelope.Tabs.Tab[1] = tab2;
envelope.Tabs.Tab[2] = tab3;
System.debug('Calling the API');
try {
DocuSignAPI.EnvelopeStatus es = dsApiSend.CreateAndSendEnvelope(envelope);
envelopeId = es.EnvelopeID;
System.debug('Returned successfully, envelope id = ' + envelopeId );
return '';
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
envelopeId = 'Exception - ' + e;
return '';
}
return '';
}
}

I resolved the issue with the DocuSign support.
MergeFieldXml for SOAP should be like this:
tab3.MergeFieldXml ='<mergefieldconfig configversion="1.0" service="salesforce"><mergefield><writeenabled>true</writeenabled><sendercanedit>true</sendercanedit><queryfrom><obj><type>Lead</type><name>Lead</name><field><fieldtype>string</fieldtype><name>Title</name></field></obj></queryfrom></mergefield></mergefieldconfig>';

Related

Apex - Test Batch class Execute method not covered code coverage

Batch apex class not covering execute method
Batch Apex Class : Trying to cover execute method but not covered in image above.
This batch class is on aggregate result. Please suggest me how to cover this batch class
It is working on search result of order if the status is based on filter then in execute method it will aggregate the value of fulfilment id of all orders related to it. based on their order status it executes.
global class UpdateOrderIntegrationStatus_Batch implements
Database.Batchable<AggregateResult>, Database.Stateful{
String status_filter = 'Waiting On Prior Order';
String query = 'select count(Id) cnt, Fulfillment__c from Apttus_Config2__Order__c'
+' where Fulfillment__c <> null and Order_Integration_Status__c = \''+status_filter + '\''
+' group by Fulfillment__c '
+' limit 50000';
public UpdateOrderIntegrationStatus_Batch(){}
public UpdateOrderIntegrationStatus_Batch(string q){
query = q;
}
global Iterable<AggregateResult> start(Database.BatchableContext BC){
//system.debug('>>>> query : ' + query)
return new AggregateResultIterable(query);
}
global void execute(Database.BatchableContext BC, List<sobject> results){
set<Id> fufillmentIds = new set<Id>();
for(Sobject sObj:results){
AggregateResult ar = (AggregateResult)sObj;
fufillmentIds.add((Id) ar.get('Fulfillment__c'));
}
List<Contract> fulfillments = [select id,(select Id, Order_Integration_Status__c from Orders__r order by Name asc) from Contract where id IN:fufillmentIds];
List<Apttus_Config2__Order__c> orderToUpdate = new List<Apttus_Config2__Order__c>();
String priorOrderIntegrationStatus = '';
for(Contract fulfillmentObj: fulfillments){
priorOrderIntegrationStatus = '';
for(Apttus_Config2__Order__c order: fulfillmentObj.Orders__r){
if(order.Order_Integration_Status__c == 'Processed'){
priorOrderIntegrationStatus = order.Order_Integration_Status__c;
}
else if(order.Order_Integration_Status__c == 'Error'){
break;
}
else if(order.Order_Integration_Status__c == status_filter && priorOrderIntegrationStatus == 'Processed' ){
order.Order_Integration_Status__c = 'Ready';
orderToUpdate.add(order);
priorOrderIntegrationStatus = order.Order_Integration_Status__c;
break;
}
else{
priorOrderIntegrationStatus = order.Order_Integration_Status__c; //For other statuses like Ready, Not Ready, Pending etc.
continue;
}
}
}
if(orderToUpdate <> null && orderToUpdate.size() > 0){
Database.update(orderToUpdate, false);
}
}
global void finish(Database.BatchableContext BC){
System.debug('UpdateOrderIntegrationStatus_Batch Finished');
}
}
Test Batch class:
#isTest
public class UpdateOrderIntegrationStatus_Batch_Test {
public static testMethod void testBatch() {
Test.StartTest();
Account acc =APTS_BvdUtility.createAccount();
Contact con = APTS_BvdUtility.createContact(acc.Id);
Apttus_Config2__AccountLocation__c acclocation = APTS_BvdUtility.createAccountLocation('Test Loc', acc.Id, con.Id);
Opportunity opp = APTS_BvdUtility.createOpportunity('Test Opp ', acc.Id, con.Id);
Apttus_Config2__PriceList__c priceList = APTS_BvdUtility.createPriceList('Test PriceBook') ;
Apttus_Proposal__Proposal__c quote = APTS_BvdUtility.createQuote(acc, opp, priceList.Id, 'quoteName');
Apttus_Config2__Order__c newOrder = new Apttus_Config2__Order__c();
newOrder.Apttus_QPConfig__ProposalId__c = quote.Id;
newOrder.Apttus_Config2__Status__c = 'Pending';
newOrder.AC_Billing_Street_1__c = '234';
newOrder.AC_Shipping_Street_1__c = '234';
newOrder.Ultimate_Parent_Account_ID__c = quote.Apttus_Proposal__Account__c;
newOrder.Apttus_Config2__BillToAccountId__c = quote.Apttus_Proposal__Account__c;
newOrder.Apttus_Config2__ShipToAccountId__c = quote.Apttus_Proposal__Account__c;
newOrder.Apttus_Config2__RelatedOpportunityId__c = quote.Apttus_Proposal__Opportunity__c;
newOrder.Apttus_Config2__OrderStartDate__c = quote.Apttus_Proposal__ExpectedStartDate__c;
newOrder.Apttus_Config2__OrderEndDate__c = quote.Apttus_Proposal__ExpectedEndDate__c;
newOrder.Apttus_Config2__SoldToAccountId__c = quote.Apttus_Proposal__Account__c;
newOrder.Apttus_Config2__PriceListId__c = quote.Apttus_QPConfig__PriceListId__c;
newOrder.Apttus_Config2__Type__c = quote.Apttus_QPConfig__ABOType__c;
newOrder.Language__c = 'English';
newOrder.Billing_Cycle__c = 'Annual';
newOrder.Detailed_Invoice__c = true;
newOrder.Bill_To_Contracting_Party__c = 'Test123';
newOrder.Ship_To_Contracting_Party__c = 'Test123';
newOrder.Bill_To_Location__c = acclocation.Id;
newOrder.Ship_To_Location__c = acclocation.id;
newOrder.Bill_To_Ultimate_Parent_Account_ID__c = quote.Apttus_Proposal__Account__c;
newOrder.Ship_To_Ultimate_Parent_Account_ID__c = quote.Apttus_Proposal__Account__c;
newOrder.Apttus_Config2__ActivatedDate__c = System.today();
newOrder.Apttus_Config2__OrderDate__c = System.today();
newOrder.CurrencyIsoCode = quote.CurrencyIsoCode;
newOrder.Apttus_Config2__ActivatedDate__c = System.Date.today();
newOrder.Order_Integration_Status__c='Waiting On Prior Order';
insert newOrder;
String testseqname = 'CONTRACT_NUMBER';
double testseqnumber = 1234;
Sequence_Number__c sn = new Sequence_Number__c(Name = testseqname, Next_Sequence_Number__c = testseqnumber);
insert sn;
List<SObject> contracts = new List<Contract>();
Contract fulfillment = new Contract();
fulfillment.Fulfillment_Total__c = 6000;
fulfillment.AccountId = acc.Id;
fulfillment.Opportunity__c = opp.Id;
fulfillment.Renewal_Opportunity__c = opp.Id;
fulfillment.CurrencyIsoCode = newOrder.CurrencyIsoCode;
fulfillment.CustomerSignedDate = system.today();
fulfillment.Status = 'Client Signed';
fulfillment.End_Date__c = newOrder.Apttus_Config2__OrderEndDate__c;
fulfillment.StartDate = newOrder.Apttus_Config2__OrderStartDate__c;
fulfillment.Latest_Order__c = newOrder.Id;
fulfillment.Billing_Integration_Status__c = 'Ready';
fulfillment.RecordTypeId = System.Label.Sales_Contract_RecordTypeID;
fulfillment.Original_Order_Submit_Date__c = newOrder.Apttus_Config2__ActivatedDate__c.date();
fulfillment.BusinessUnit__c = 'Bureau van Dijk Electronic Publishing Inc.';
fulfillment.Contract_Sequence_Number__c = 993360;
// insert fulfillment;
contracts.add(fulfillment);
insert contracts;
List<Contract> contrList = [select id,(select Id, Order_Integration_Status__c from Orders__r order by Name asc) from Contract where id =:contracts[0].Id];
newOrder.Order_Integration_Status__c='Processed';
update newOrder;
String status_filter = 'Waiting On Prior Order';
String query = 'select count(Id) cnt, Fulfillment__c from Apttus_Config2__Order__c'
+' where Fulfillment__c <> null and Order_Integration_Status__c = \''+status_filter + '\''
+' group by Fulfillment__c '
+' limit 50000';
/* String query = 'select id,(select Id, Order_Integration_Status__c from Orders__r order
by Name asc) from Contract';
String query = 'select count(Id) cnt, Fulfillment__c from Apttus_Config2__Order__c'
+' where Fulfillment__c =\''+contrList[0].Id +'\' and Order_Integration_Status__c =
\''+status_filter + '\''
+' group by Fulfillment__c '
+' limit 50000';
*/
UpdateOrderIntegrationStatus_Batch obj = new UpdateOrderIntegrationStatus_Batch();
UpdateOrderIntegrationStatus_Batch obj1 = new UpdateOrderIntegrationStatus_Batch(query);
// obj1.execute(BC, contracts);
ID batchprocessid = Database.executeBatch(obj);
ID batchprocessid1 = Database.executeBatch(obj1,10);
List<Apttus_Config2__Order__c> orders =[select Id,
Order_Integration_Status__c,Fulfillment__c from Apttus_Config2__Order__c where
Fulfillment__c=:contracts[0].Id];
for(Apttus_Config2__Order__c ord : orders){
system.assertEquals('Processed', ord.Order_Integration_Status__c);
}
Test.StopTest();
}
}

How to duplicate line on itself?

In a JetBrains editor, what is the shortcut (or trick) to duplicate a line on itself without breakline (not like Ctrl + D). In other words, I want to turn this:
constructor(obj: Schema$Car) {
this.brand =
this.id =
this.model =
this.photoBack =
this.photoFront =
this.photoInteriorBack =
this.photoInteriorFront =
this.photoSide =
this.seatCount =
this.year =
}
into this:
constructor(obj: Schema$Car) {
this.brand = obj.brand
this.id = obj.id
this.model = obj.model
this.photoBack = obj.photoBack
this.photoFront = obj.photoFront
this.photoInteriorBack = obj.photoInteriorFront
this.photoInteriorFront = obj.photoInteriorFront
this.photoSide = obj.photoSide
this.seatCount = obj.seatCount
this.year = obj.year
}

How to get Rates from UPS Rate API?

I am using nopcommerce 3.5. I have added plugin of UPS of TransitInTime and Rate API. I want to get rates by calling UPS Rate API. I want all Rates in dropdown on page load.
So for the first I am using test application using webservices of RateWebReference and in which I get only one Rate but I want Rates for all shipping option.
Here is my code of RateWSClient.cs
RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = "CC....";
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = "gi..";
upssUsrNameToken.Password = "Ch..";
upss.UsernameToken = upssUsrNameToken;
rate.UPSSecurityValue = upss;
RequestType request = new RequestType();
String[] requestOption = { "Rate" };
request.RequestOption = requestOption;
rateRequest.Request = request;
ShipmentType shipment = new ShipmentType();
ShipperType shipper = new ShipperType();
shipper.ShipperNumber = "A65V88";
RateWSSample.RateWebReference1.AddressType shipperAddress = new RateWSSample.RateWebReference1.AddressType();
String[] addressLine = { "", "", "" };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "";
shipperAddress.PostalCode = "30076";
shipperAddress.StateProvinceCode = "GA";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;
shipment.Shipper = shipper;
ShipFromType shipFrom = new ShipFromType();
RateWSSample.RateWebReference1.AddressType shipFromAddress = new RateWSSample.RateWebReference1.AddressType();
shipFromAddress.AddressLine = addressLine;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "30076";
shipFromAddress.StateProvinceCode = "GA";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;
shipment.ShipFrom = shipFrom;
ShipToType shipTo = new ShipToType();
ShipToAddressType shipToAddress = new ShipToAddressType();
String[] addressLine1 = { "", "", "" };
shipToAddress.AddressLine = addressLine1;
shipToAddress.City = "";
shipToAddress.PostalCode = "92262";
shipToAddress.StateProvinceCode = "";
shipToAddress.CountryCode = "US";
shipTo.Address = shipToAddress;
shipment.ShipTo = shipTo;
CodeDescriptionType service = new CodeDescriptionType();
//Below code uses dummy date for reference. Please udpate as required.
service.Code = "02";
shipment.Service = service;
PackageType package = new PackageType();
PackageWeightType packageWeight = new PackageWeightType();
packageWeight.Weight = "125";
CodeDescriptionType uom = new CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;
CodeDescriptionType packType = new CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;
PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
//Shipping Rate Chart
// ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
//SRO.RateChartIndicator = "";
//shipment.ShipmentRatingOptions= SRO;
//rateRequest.Shipment = shipment;
ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
SRO.NegotiatedRatesIndicator = "";
shipment.ShipmentRatingOptions = SRO;
rateRequest.Shipment = shipment;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
Console.WriteLine(rateRequest);
RateResponse rateResponse = rate.ProcessRate(rateRequest);
Console.WriteLine("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
Console.WriteLine("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
Console.ReadKey();
I have resolved this questions. So If you face this kind of problem don't forget to use
String[] requestOption = { "Shop" };
in place of
String[] requestOption = { "Rate" };
Then you will get rates for all shipping options.

Having error in updating my record in database my method as follows

What I have done wrong in this code ? (I am using MVC4 and EF)
As an example: Please clear this am fresher to use MVC4
EditResponse response = new EditResponse();
try
{
using (WeMatchContext db = new WeMatchContext())
{
B_MEMBER_REGISTER update = new B_MEMBER_REGISTER();
var output = db.B_MEMBER_REGISTER.Where(x => x.MEMBER_ID == model.MEMBER_ID).FirstOrDefault();
if(output != null )
{
update.FIRST_NAME = model.FIRST_NAME;
update.LAST_NAME = model.LAST_NAME;
update.GENDER = model.GENDER;
update.DOB = model.DOB;
int resultcount = db.SaveChanges();
if (resultcount > 0)
{
response.MEMBER_ID = update.MEMBER_ID;
response.ResultCode = 0;
response.Message = "Updated Successfully";
}
You have to attach updated data with the db entity. please try this,
using (WeMatchContext db = new WeMatchContext())
{
var update = db.B_MEMBER_REGISTER.Where(x => x.MEMBER_ID == model.MEMBER_ID).FirstOrDefault();
if(update != null )
{
update.FIRST_NAME = model.FIRST_NAME;
update.LAST_NAME = model.LAST_NAME;
update.GENDER = model.GENDER;
update.DOB = model.DOB;
//below line of code is very important.
db.B_MEMBER_REGISTER.Attach(update);
db.Entry(update).State = EntityState.Modified;
int resultcount = db.SaveChanges();
if (resultcount > 0)
{
response.MEMBER_ID = update.MEMBER_ID;
response.ResultCode = 0;
response.Message = "Updated Successfully";
}
}
}

How to get the list of unsubscribers emails from mailchimp

I want to get the emails of unsubscribers the code below returning the count that how many of it are there but how could i get the List of unsubscribers from output variable...
Here is my full code::
private List<campaignUnsubscribesResults.Unsubscribes> Unsubscribers = new List<campaignUnsubscribesResults.Unsubscribes>();
private void GetUnsubscribers(string apikey, string MailChimpCampaignID)
{
campaignUnsubscribesInput input = new campaignUnsubscribesInput();
input.api_AccessType = PerceptiveMCAPI.EnumValues.AccessType.Serial;
input.api_CustomErrorMessages = true;
input.api_MethodType = PerceptiveMCAPI.EnumValues.MethodType.POST;
input.api_Validate = true;
input.api_OutputType = PerceptiveMCAPI.EnumValues.OutputType.XML;
input.parms.apikey = apikey;
input.parms.cid = MailChimpCampaignID;
//input.parms.start = PageIndex;
//input.parms.limit = PageSize;
campaignUnsubscribes unsubscribe = new campaignUnsubscribes();
campaignUnsubscribesOutput output = unsubscribe.Execute(input);
Unsubscribers.AddRange(output.result.data);
string unsubscriber = "0";
//ArrayList a = new ArrayList();
//a[0] = output.result.data.ToString();
//List<MCItem> lst = new List<MCItem>();
// foreach (listBatchUnsubscribeResults order in myArrayList)
//{
// orders.add(order);
//}
string[] unsubs;
//ArrayList [] list = new ArrayList [0];
foreach (listMembers list1 in output.result)
{
unsubscriber = list1.ToString();
}
string unsubscribers = Unsubscribers.Count.ToString();
Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('Unsubscribers:: '+ ' " + unsubscribers + " ');</script>");
//Unsubscribers.Reverse();
//dlUnsubscribes.DataSource = Unsubscribers.Take(10);
//dlUnsubscribes.DataBind();
//dlUnsubscribes.Visible = (Unsubscribers.Count > 0);
}
I would use Mailchimp Webhooks. You setup a page/script on your website which will get called by Mailchimp every time a particular event occurs. When it's an unsubscribe event, you can log the info you want to store to a database, file, etc.