• Mario Conteddu 1
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 9
    Replies
Hi Guys,
I need to write a trigger which will tick a checkbox in contact when the contact is member of a specific campaign. Furthermore, I need the same checkbox to be un-ticked when the contact has a date (end date) on a custom field which I created in the campaign member object.
I managed to get the checkbox ticked but I can't get it unticked when an end date is added. Can you please help me?
 
trigger updateContact on CampaignMember (before update){
  List<id> contactIds=new List<Id>();
  for(CampaignMember cm:trigger.new){
    if(cm.ContactId != null){
      System.debug('End Date of campaign membership is ' + cm.CM_End_Date__c);
      if(cm.CM_End_Date__c == null && cm.campaignId == '701b0000000FY9Z'){
        contactIds.add(cm.ContactId);
        System.debug('Id is ' + cm.ContactId);
      }  
    }
  }
  List<Contact> contacts=[SELECT Id,    TestTrustee__c FROM Contact WHERE Id IN : contactIds];
  for(Contact c:contacts){
      System.debug('Found contact ' + c);
    c.TestTrustee__c=True;
      system.debug('Trustee status is now '+c.TestTrustee__c );
  }

}

 
Hi,

I've need to get a Contact checkbox field =TRU when the same contact is a campaign member of a specific campaign. Can you please help me? 

Would it be possibile to filter null long text area fields in SOQL?

I need to run process where if a number of text area fields in contact are null then do something.

Thanks in advance!

 

Hi All,

I am very new to programming and I am trying to takle my first challenge...

I need to create a trigger which check/uncheck a checkbox on the contact record when a checkbox is checked/unchecked on a custom object. 

The custom object has a child relationship with Contact object. 

I have Ok_to_Welcome_Email__c on both custom object and Contact object - they should basically get synced, the custom object will be the master for the syncronization.

following anothe post, I've written the following code which clearly does not work:
 
trigger updateOkToWelcomeEmail on CustomObject__c (before insert, before update) {   
    List<Contact> ContactList = new List<Contact>();
    List<Id> contactId        = new List<Id>();
        For(CustomObject__c fa : Trigger.new) {
           if(fa.ok_to_welcome_email__c = True) {
               contactId.add(fa.Contact__c);
                }
                }
contactList = [SELECT Id, ok_to_welcome_email__c FROM Contact WHERE Contact__c IN : contactId];
    for(Contact l : contactList) {
        l.ok_to_welcome_email__c = true;
        }
        update contactList;
}





 

Would it be possibile to filter null long text area fields in SOQL?

I need to run process where if a number of text area fields in contact are null then do something.

Thanks in advance!

 

Hi Guys,
I need to write a trigger which will tick a checkbox in contact when the contact is member of a specific campaign. Furthermore, I need the same checkbox to be un-ticked when the contact has a date (end date) on a custom field which I created in the campaign member object.
I managed to get the checkbox ticked but I can't get it unticked when an end date is added. Can you please help me?
 
trigger updateContact on CampaignMember (before update){
  List<id> contactIds=new List<Id>();
  for(CampaignMember cm:trigger.new){
    if(cm.ContactId != null){
      System.debug('End Date of campaign membership is ' + cm.CM_End_Date__c);
      if(cm.CM_End_Date__c == null && cm.campaignId == '701b0000000FY9Z'){
        contactIds.add(cm.ContactId);
        System.debug('Id is ' + cm.ContactId);
      }  
    }
  }
  List<Contact> contacts=[SELECT Id,    TestTrustee__c FROM Contact WHERE Id IN : contactIds];
  for(Contact c:contacts){
      System.debug('Found contact ' + c);
    c.TestTrustee__c=True;
      system.debug('Trustee status is now '+c.TestTrustee__c );
  }

}

 
Hi,

I've need to get a Contact checkbox field =TRU when the same contact is a campaign member of a specific campaign. Can you please help me? 

Would it be possibile to filter null long text area fields in SOQL?

I need to run process where if a number of text area fields in contact are null then do something.

Thanks in advance!

 

Hi All,

I am very new to programming and I am trying to takle my first challenge...

I need to create a trigger which check/uncheck a checkbox on the contact record when a checkbox is checked/unchecked on a custom object. 

The custom object has a child relationship with Contact object. 

I have Ok_to_Welcome_Email__c on both custom object and Contact object - they should basically get synced, the custom object will be the master for the syncronization.

following anothe post, I've written the following code which clearly does not work:
 
trigger updateOkToWelcomeEmail on CustomObject__c (before insert, before update) {   
    List<Contact> ContactList = new List<Contact>();
    List<Id> contactId        = new List<Id>();
        For(CustomObject__c fa : Trigger.new) {
           if(fa.ok_to_welcome_email__c = True) {
               contactId.add(fa.Contact__c);
                }
                }
contactList = [SELECT Id, ok_to_welcome_email__c FROM Contact WHERE Contact__c IN : contactId];
    for(Contact l : contactList) {
        l.ok_to_welcome_email__c = true;
        }
        update contactList;
}