You need to sign in to do that
Don't have an account?
Create a Relationship Query
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);
}
}
}
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);
}
}
}
So are you getting any error while querying the records, you can use the query editor on the developer console to see if the query is returning records.
I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be used by others in the future.
Regards,
Anutej
We can’t find the correct SOQL query in the PropertyUtility class.
Please try this:
public class PropertyUtility {
public static void newListedProperties(){
List<Property__c> newPropList = [Select Name,Days_On_Market__c,Broker__r.Email__c from Property__c where Days_On_Market__c < 31];
for(Property__c p : newPropList){
string propEmail = p.Name +':'+ p.Broker__r.Email__c ;
system.debug(propEmail);
}
}
}
public class PropertyUtility {
public static void newListedProperties(){
List<Property__c> newPropList = [Select Name,id,Days_On_Market__c,Broker__r.Email__c from Property__c where Days_On_Market__c <31];
for(Property__c proplist :newPropList){
String propEmail = proplist.name+':'+proplist.Broker__r.Email__c;
system.debug(propEmail);
}
}
}
String propEmail = newPropList[0].Name + ':' + newPropList[0].Broker__r.Email__c ;
Here is the complete code. It should work fine.
public class PropertyUtility {
public static void newListedProperties(){
List<Property__c> newPropList = [SELECT Name , Broker__r.Email__C , Days_On_Market__c FROM Property__c WHERE Days_On_Market__c<31] ;
for(Property__c Result : newPropList){
String propEmail = newPropList[0].Name + ':' + newPropList[0].Broker__r.Email__c ;
System.Debug(propEmail);
}
}
}
public static void newListedProperties(){
//SELECT Id, Days_On_Market__c, Name FROM Property__c
//SELECT Id, Email__c FROM Broker__c
//Broker__c is the parent of Property__c, dot natation is used and r for the relationship
//SELECT Name, Broker__r.Email__c,Days_On_Market__c FROM Property__c;
List <Property__c> newPropList =
[SELECT Name, Broker__r.Email__c,Days_On_Market__c
FROM Property__c WHERE Days_On_Market__c <= 30];
for (Property__c prop : newPropList){
String propEmail = 'Property Name: ' + prop.Name +'Broker Email: '+ prop.Broker__r.Email__c;
system.debug(propEmail);
}
}
public static void newListedProperties(){
List<Property__c> newPropList = [SELECT Name, Days_On_Market__c, Broker__r.Email__c FROM Property__c where Days_On_Market__c <31];
for (Property__c proplist : newPropList){
String propEmail = 'Property Name: ' + proplist.Name + ', Brokers email: ' + proplist.Broker__r.Email__c;
system.debug(propEmail);
}
}
}
Public Static Void newListedPropertie()
{
List<Property__c> newPropList=[SELECT Name, Broker__r.Email__c,Days_On_Market__c FROM Property__c where Date_Listed__c= LAST_N_DAYS:30];
for (Property__c Prop: newPropList)
{
String propEmail= 'Property Name'+Prop.Name+':' +'Broker Email'+Prop.Broker__r.Email__c;
System.debug(propEmail);
}
}
}
public class PropertyUtility {
public static void newListedProperties(){
List<Property__c> newPropList = [Select Name,id,Days_On_Market__c,Broker__r.Email__c from Property__c where Days_On_Market__c <31];
for(Property__c proplist :newPropList){
String propEmail = proplist.name+':'+proplist.Broker__r.Email__c;
system.debug(propEmail);
}
}
}
public class PropertyUtility {
public static void newListedProperties(){
List<Property__c> newPropList = [SELECT Name, Broker__r.Email__C, Days_On_Market__c FROM Property__c WHERE Days_On_Market__c < 31];
for (Property__c prop : newPropList){
String propEmail = 'Property Name:' + prop.Name + 'Property Name:' 'Broker Email' + prop.Broker__r.Email__C;
system.debug(propEmail);
}
}
}
https://themanagementpros.com/