• Bobby Steele 9
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I am fairly new to writing triggers, so I took a shot at this one because I thought it would be pretty simple. I have looked a tons of example and can't seem to figure out what I am doing wrong. I would like to update base address information from a field called Metro Area when address is null. However I keep getting the error "Expression cannot be a statement at line 4 column 14".
Code is listed below:

trigger UpdateMailingAddressMetro on Contact (Before Insert, Before Update) {
    for(contact c: trigger.new){
        If(c.Metro_Area__c.contains('Houston') && (c.mailingcity == NULL) && (c.mailingstate == NULL) && (c.mailingpostalcode == NULL)){
            (c.mailingcity == 'Houston');
            (c.mailingstate == 'TX');
            (c.mailingpostalcode == '77001');
            (c.mailingcountry == 'United States');
                }else {
                    c.mailingstate == NULL;
                    }
        }
}
I am fairly new to writing triggers, so I took a shot at this one because I thought it would be pretty simple. I have looked a tons of example and can't seem to figure out what I am doing wrong. I would like to update base address information from a field called Metro Area when address is null. However I keep getting the error "Expression cannot be a statement at line 4 column 14".
Code is listed below:

trigger UpdateMailingAddressMetro on Contact (Before Insert, Before Update) {
    for(contact c: trigger.new){
        If(c.Metro_Area__c.contains('Houston') && (c.mailingcity == NULL) && (c.mailingstate == NULL) && (c.mailingpostalcode == NULL)){
            (c.mailingcity == 'Houston');
            (c.mailingstate == 'TX');
            (c.mailingpostalcode == '77001');
            (c.mailingcountry == 'United States');
                }else {
                    c.mailingstate == NULL;
                    }
        }
}