• Alberto Acosta
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Create a query and assign the query results to the list
Get this information:
The name of the property
The broker’s email address
How long the property has been on market
(Hint: Use API names, not field names or field labels)
Object: Property

I WANT TO KNOW HOW TO WRITE BELOW QUERY FOR PROPERTY LISTED IN LAST 30 DAYS....

Condition: The property was listed within the last 30 days

public class PropertyUtility {
    public static void newListedProperties(){
        //list<Property__c> newPropList= new List<Property__c>();
        List<Property__c> newPropList=[select name,  broker__r.email__c from Property__c where CreatedDate= LAST_N_DAYS:30];
        //newPropList.add(pro);
        
        for(Property__c p:newPropList){
             String propEmail=  +p.name+ ':' +p.broker__r.email__c;
            system.debug(propEmail);
            
        }
        
    }

}
When attempting to create my Apex trigger for this Trailhead development exercise, I receive an error. I don't understand how this is possible, because the records haven't been updated, and still aren't updating.
"Challenge not yet complete... here's what's wrong:
Setting 'Match_Billing_Address__c' to false updated the records anyway. The trigger should only act when Match_Billing_Address__c is true."


Here's my code:
trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }

}