3

I am running into the following error while querying CampaignMember:

-------------- Failed ----------CampaignMember [BatchInfo id='751c0000001HqUQAA0' jobId='750c0000001Mpg1AAC' state='Failed' stateMessage='InvalidBatch : Failed to process query: INVALID_FIELD: SystemModstamp, FirstRespondedDate, Name, tt_itda_watch__Tech_Target_Import_Timestamp__c
^ ERROR at Row:1:Column:174 No such column 'Name' on entity 'CampaignMember'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.' createdDate='java.util.GregorianCalendar[time=1440705023000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2015,MONTH=7,WEEK_OF_YEAR=35,WEEK_OF_MONTH=5,DAY_OF_MONTH=27,DAY_OF_YEAR=239,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=7,HOUR_OF_DAY=19,MINUTE=50,SECOND=23,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]' systemModstamp='java.util.GregorianCalendar[time=1440705023000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2015,MONTH=7,WEEK_OF_YEAR=35,WEEK_OF_MONTH=5,DAY_OF_MONTH=27,DAY_OF_YEAR=239,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=7,HOUR_OF_DAY=19,MINUTE=50,SECOND=23,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]' numberRecordsProcessed='0' numberRecordsFailed='0' totalProcessingTime='0' apiActiveProcessingTime='0' apexProcessingTime='0' ]

And the query is:

SELECT Id, IsDeleted, CampaignId, LeadId, ContactId, Status, HasResponded, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, FirstRespondedDate, Name, tt_itda_watch__Tech_Target_Import_Timestamp__c FROM CampaignMember WHERE SystemModStamp <= 2015-08-28T12:23:26.760Z 

Running the query in Developer console does not return any error message. The problem disappears when I remove the Name field. Is this an issue from Salesforce and if not, how can I replicate the data using Bulk API?

1 Answer 1

2

When querying "name" off of CampaignMember, you're actually referring to the name of a contact or lead that the campaignMember record has a relationship with. So unlike the field "Name" on Account or a similar object, you're not referring to the CampaignMember's name, you're attempting to refer to a compound field which is the FirstName + LastName value retrieved from the Contact or Lead.

Although I'm not an expert on this, there are some situations where the Developer Console will let you query compound fields without issue, but if you try that in an Apex class, it won't let you.

So if you want to retrieve the "name" values, I'd suggest putting

Contact.FirstName, Contact.LastName

or

Lead.FirstName, Lead.LastName

Or both of those in your query (depending on whether you're looking for lead campaigns, contact campaigns, or all campaigns), in place of "Name".

4
  • The problem is I do not know what ones that I have to look for - Contact or Lead. So, the solution should be running two separate batches using the where clause where LeadId != null and where ContactId != null. I guess I can use Contact.Name instead of FirstName, LastName fields.
    – dmachop
    Aug 28, 2015 at 19:28
  • 1
    Relationship query not supported through Bulk. Therefore, this solution is not possible!
    – dmachop
    Aug 28, 2015 at 20:06
  • You are correct, I overlooked the "bulk API" note at the end of your original description, my apologies. However, you had mentioned batches in your follow up comment - it would work there.
    – KB145
    Aug 28, 2015 at 20:29
  • What I meant was create a job and use individual batches to integrate. As I would require name field, the batch will still fail.
    – dmachop
    Aug 28, 2015 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .