I'm trying to use FormAssembly to build a registration form for trainings that will be tracked as campaigns in Salesforce. Training attendees are invited by email but sometimes pass their invitations along to others who were not invited (which is a good thing in this case). The invitees are already part of the campaign.
I'm having trouble figuring out how to update campaign member records when they are available OR create campaign member records when a match isn't found (using Contact ID and Campaign ID as the lookup criteria). The problem is that when you update a campaign member record and pass the Campaign ID, you get an error message saying you can't update the Campaign ID on a campaign member record (which makes sense since it's a child record in a master-detail relationship) but if you DON'T include the Campaign ID, you can't create a campaign member record if one isn't found.
Any ideas on how I can do both?
(It would work if there was lookup criteria that allowed you to say "If one matching record is found: Do nothing", but that's not an option.)
To recap, I need to be able to handle three scenarios:
The contact is not in Salesforce; they need to be added to the campaign. The contact is already in Salesforce; they are already part of the campaign but need to have their status updated. The contact is already in Salesforce; they need to be added to the campaign.
The mechanism to do this is to use our Salesforce object logic the 'If zero records found, do X; if one record found, do Y; if multiple records found, do Z;' as described here: http://www3.formassembly.com/blog/support-documentation/connectors-documentation/salesforce-documentation/using-the-version-2-salesforce-connector/#update
Basically, this is logic you would do:
1. Lookup Contact (if zero records found, or many records found, skip this object and depedents; if one record found, continue) 2. Create new CampaignMember Contact.Id = Get Id from 1. CampaignId = 000xx00x00 Status = 'Responded'
3. Lookup Contact (if zero records found, or many records found, continue; if one record found, skip this object and dependents) 4. Create new Contact Last Name = get from Form Field "Last Name" .... 5. Create new CampaignMember Contact Id = get id from 4. CampaignId = 000xx00x00 Status = 'Responded'
I think Salesforce will be smart enough to handle things from there, but let me know how it goes.
Thanks for your response, Drew! The problem is not with creating or updating the contact record - I've got that part. The problem is with creating or updating a campaign member record. When you use the mechanism described above ("if no records found, do x; if one record found, do y ...") it uses the same field mapping regardless of whether you're creating or updating a record.
If your field mapping does not include the Campaign ID, the attempt to create a new campaign member record will fail with a message of "Create CampaignMember - Invalid campaign id: null"
If your field mapping includes the Campaign ID, the attempt to update an existing campaign member record will fail with a message of "Update CampaignMember - Unable to create/update fields: CampaignId. Please check the security settings of this field and verify that it is read/write for your profile."
I'm not sure how to get around this, as we're working both with people who were invited to an event (already campaign members) and anyone they invite (not campaign members). I'm happy to provide you with screenshots of my configuration if you want to make sure I didn't miss anything.
In that case, you can add an additional clause for each 'Create New CampaignMember' for whom it makes sense that there might be an existing CampaignMember record so that it looks like this:
7. Look up CampaignMember: ContactId equals Get id from from Object # CampaignId equals Formula: xxx00xx00 if 0 found or many found, continue, if 1 found, skip. 8. Create New CampaignMember ...fields...
9. Look up CampaignMember: ContactId equals Get id from from Object # CampaignId equals Formula: xxx00xx00 if 1 found, continue. if 0 or many found, skip. 10. Update CampaignMember CampaignMemberId equals result from lookup #9. Status = 'responded'
There's no option to skip if one record is found. The only option is: Update record (default). Maybe I could suppress the error in Salesforce and cause the insert to fail silently? It would be better to have a way to deal with this before the data is sent.
I think I'm losing the thread a bit as we talk about this in the abstract here on the forum. Can you open support request and let us know the form id of the form you're working with.