• Dan Rogers
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

I'm new to Apex Code / SOQL.

I'm trying to write a trigger based on someone's Mailchimp Interest Lists. I can the value I need no problem if I run SOQL directly, e.g.
 
select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = '00Q24000004bfgYEAQ'

gives me the result I need:

User-added image
But whatever I do I can't seem to get access to this value in Apex Code, e.g. this is the trigger:
 
trigger updateMCStatus on Lead (after update) {

    Map<String, Lead> leadMap = new Map<String, Lead>();

    for (Lead lead : System.Trigger.new) {

        System.Debug('lead mc interests: ' + lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c);
        System.Debug('lead mc subscriber: ' + lead.MC4SF__MC_Subscriber__c);
		
        String query = 'select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = \'' + String.escapeSingleQuotes(lead.Id) + '\'';
        
        System.Debug(query);
        	
        List<sObject> sobjList = Database.query(query);
		
        System.Debug('object: ' + sobjList[0]);
        
    }

}

Results of those debugs:

lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c = null
lead.MC4SF__MC_Subscriber__c = a0B24000004BPMnEAO
(the SOQL query) sobjList[0] =  Lead:{MC4SF__MC_Subscriber__c=a0B24000004BPMnEAO, Id=00Q24000004bfgYEAQ}​

Is there anything I can do to get this value :) ? It's driving me crazy.

Cheers!

Dan



 
Hi,

I'm new to Apex Code / SOQL.

I'm trying to write a trigger based on someone's Mailchimp Interest Lists. I can the value I need no problem if I run SOQL directly, e.g.
 
select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = '00Q24000004bfgYEAQ'

gives me the result I need:

User-added image
But whatever I do I can't seem to get access to this value in Apex Code, e.g. this is the trigger:
 
trigger updateMCStatus on Lead (after update) {

    Map<String, Lead> leadMap = new Map<String, Lead>();

    for (Lead lead : System.Trigger.new) {

        System.Debug('lead mc interests: ' + lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c);
        System.Debug('lead mc subscriber: ' + lead.MC4SF__MC_Subscriber__c);
		
        String query = 'select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = \'' + String.escapeSingleQuotes(lead.Id) + '\'';
        
        System.Debug(query);
        	
        List<sObject> sobjList = Database.query(query);
		
        System.Debug('object: ' + sobjList[0]);
        
    }

}

Results of those debugs:

lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c = null
lead.MC4SF__MC_Subscriber__c = a0B24000004BPMnEAO
(the SOQL query) sobjList[0] =  Lead:{MC4SF__MC_Subscriber__c=a0B24000004BPMnEAO, Id=00Q24000004bfgYEAQ}​

Is there anything I can do to get this value :) ? It's driving me crazy.

Cheers!

Dan