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?
Solved! Go to Solution.
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;
}
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.
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.
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;
}
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;
}