Retrieve LISTS associated with CAMPAIGN

SOLVED
Go to solution
Frequent Participant

Retrieve LISTS associated with CAMPAIGN

I have successfully used the API to associate a LIST with a CAMPAIGN but when I retrieve the CAMPAIGN the CONTACTLISTS array is empty. Is there some other method of retrieving the LISTS associated with a CAMPAIGN?

1 ACCEPTED SOLUTION
Frequent Participant

Added the following to CampaignsCollection.createCampaignStruct()

 

Similar to code in ContactsCollection.createContactStruct(). This code is CF9 and above I believe, see the contacts example for a backwards compatible version if needed.

 

if(structKeyExists(local.tempStruct, "ContactLists"))

{

local.contactLists = [];

for(i=1; i <= arrayLen(local.tempStruct.ContactLists.ContactList); i++)

{

local.contactLists[i] = local.tempStruct.ContactLists.ContactList[i].xmlAttributes.id;

 }

local.campaign['contactLists'] = local.contactLists;

}

View solution in original post

4 REPLIES 4
Employee

Hey,

 

Once you associate the list you should be able to pull the lists straight out of the Campaign.

 

 <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/Username/lists/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/Username/lists/1" rel="self"></link>
        </ContactList>
        <ContactList id="http://api.constantcontact.com/ws/customers/Username/lists/9">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/Username/lists/9" rel="self"></link>
        </ContactList>
      </ContactLists>

 That is an actual response from my campaign in my account. Please supply your code and we can try to troubleshoot it for you.

Ryan Davis
Quality Engineer
Occasional Participant

Digging deeper has revealed a failure in the supplied Coldfusion code. It does not carry the list of lists over from the response to the final structure. Working on fixing it and I'll send you the code snippet.

 

Frequent Participant

Added the following to CampaignsCollection.createCampaignStruct()

 

Similar to code in ContactsCollection.createContactStruct(). This code is CF9 and above I believe, see the contacts example for a backwards compatible version if needed.

 

if(structKeyExists(local.tempStruct, "ContactLists"))

{

local.contactLists = [];

for(i=1; i <= arrayLen(local.tempStruct.ContactLists.ContactList); i++)

{

local.contactLists[i] = local.tempStruct.ContactLists.ContactList[i].xmlAttributes.id;

 }

local.campaign['contactLists'] = local.contactLists;

}

View solution in original post

Frequent Participant

Be sure and put those loop counters in local scope. Needs to be done elsewhere in the collection as well or they step on each other.

 

if(structKeyExists(local.tempStruct, "ContactLists"))

{

local.contactLists = [];

for(local.i=1; i <= arrayLen(local.tempStruct.ContactLists.ContactList); local.i++)

local.contactLists[local.i] = local.tempStruct.ContactLists.ContactList[local.i].xmlAttributes.id;

 

local.campaign['contactLists'] = local.contactLists;

}

Developer Portal

View API documentation, code samples, get your API key.

Visit Page