• shaqib ahmad
  • NEWBIE
  • 55 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
I am getting an error System.LimitException: Too many SOQL queries: 101 .
my code.
trigger contactaccountrelation on Contact (before insert) {
 
       list<account> acc = [select id, name from account];
    for(account a : acc){
    for(contact con : [select lastname, accountid from contact where accountid =: a.id]){
        con.OtherPhone = a.Phone;
    }
    }
}
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);
            
        }
        
    }

}
<apex:page id="page" >
    <apex:form id="fm">
        <script>
          function show(){
              var Name= document.getElementById("page:fm:pb:pbs:pbsi1:name").value;
              document.getElementById('page:fm:pb:pbs:pbsi2:myName').value=Name;
              document.getElementById('page:fm:pb:pbs:pbsi3:res').innerHTML='<b><i>'+Name+'<i><b>';
             }
              </script>
        <apex:pageBlock title="Employee" id="pb" >
            <apex:pageBlockSection id="pbs" columns="1">
                
                <apex:pageBlockSectionItem id="pbsi1">
                    <apex:outputLabel value="Enter Name"/>
                    <apex:inputText id="Name" onchange="Show()" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi2">
                    <apex:outputLabel value="Your name"/>
                    <apex:inputText id="myName" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi3">
                    <apex:outputLabel value="my name"/>
                    <apex:outputText id="res"/>
                </apex:pageBlockSectionItem>
                
                
            
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
<apex:page id="page" >
    <apex:form id="fm">
        <script>
          function show(){
              var Name= document.getElementById("page:fm:pb:pbs:pbsi1:name").value;
              document.getElementById('page:fm:pb:pbs:pbsi2:myName').value=Name;
              document.getElementById('page:fm:pb:pbs:pbsi3:res').innerHTML='<b><i>'+Name+'<i><b>';
             }
              </script>
        
        <apex:pageBlock title="Employee" id="pb" >
            <apex:pageBlockSection id="pbs" columns="1">
                
                <apex:pageBlockSectionItem id="pbsi1">
                    <apex:outputLabel value="Enter Name"/>
                    <apex:inputText id="Name" onchange="Show()" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi2">
                    <apex:outputLabel value="Your name"/>
                    <apex:inputText id="myName" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi3">
                    <apex:outputLabel value="Name"/>
                    <apex:outputText id="res"/>
                </apex:pageBlockSectionItem>
                
            
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Apex class 
public class productinfo{
    public string name;
    public double price;
    public integer quantity;

}
apex code


productinfo[] products =new productinfo[4];
productinfo p1= new productinfo();
p1.name='iphone';
p1.price=50000;
p1.quantity =2;
products[0]=p1; 
//system.debug('the name is'+ p1);
productinfo p2= new productinfo();
p2.name='sumsung';
p2.price=8888;
p2.quantity=9;
products[1]=p2;
//System.debug('the name of p2 '+p2);
productinfo p3=new productinfo();
p3.name='blackberry';
p3.price=3333;
p3.quantity=4;
products[2]=p3;
//system.debug('the details of p3 '+p3);

for(productinfo p :products)
{
    system.debug(p.name);
    system.debug(p.quantity);
    system.debug(p.price);
}
 
public class Dog 
{
   private String name;
    private Integer age;
    
    public void setName(String n)
    {
      name=n;  
    }
    public void SetAge(integer j)
    {
        age=j;
    }
    public String getName()
    {
        return name;
    }
    
    public Integer getAge()
    {
        return age;
    }
    public void bark ()
    {
        
        
        System.debug('');
    }
    

}
///
I am using this apex code 
Dog d1=new Dog();
d1.setName=('frido');
d1.setAge=12;
System.debug('the name is '+d1.getName() +'' +d1.getAge());
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);
            
        }
        
    }

}
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);
            
        }
        
    }

}
<apex:page id="page" >
    <apex:form id="fm">
        <script>
          function show(){
              var Name= document.getElementById("page:fm:pb:pbs:pbsi1:name").value;
              document.getElementById('page:fm:pb:pbs:pbsi2:myName').value=Name;
              document.getElementById('page:fm:pb:pbs:pbsi3:res').innerHTML='<b><i>'+Name+'<i><b>';
             }
              </script>
        <apex:pageBlock title="Employee" id="pb" >
            <apex:pageBlockSection id="pbs" columns="1">
                
                <apex:pageBlockSectionItem id="pbsi1">
                    <apex:outputLabel value="Enter Name"/>
                    <apex:inputText id="Name" onchange="Show()" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi2">
                    <apex:outputLabel value="Your name"/>
                    <apex:inputText id="myName" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi3">
                    <apex:outputLabel value="my name"/>
                    <apex:outputText id="res"/>
                </apex:pageBlockSectionItem>
                
                
            
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
<apex:page id="page" >
    <apex:form id="fm">
        <script>
          function show(){
              var Name= document.getElementById("page:fm:pb:pbs:pbsi1:name").value;
              document.getElementById('page:fm:pb:pbs:pbsi2:myName').value=Name;
              document.getElementById('page:fm:pb:pbs:pbsi3:res').innerHTML='<b><i>'+Name+'<i><b>';
             }
              </script>
        
        <apex:pageBlock title="Employee" id="pb" >
            <apex:pageBlockSection id="pbs" columns="1">
                
                <apex:pageBlockSectionItem id="pbsi1">
                    <apex:outputLabel value="Enter Name"/>
                    <apex:inputText id="Name" onchange="Show()" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi2">
                    <apex:outputLabel value="Your name"/>
                    <apex:inputText id="myName" />
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="pbsi3">
                    <apex:outputLabel value="Name"/>
                    <apex:outputText id="res"/>
                </apex:pageBlockSectionItem>
                
            
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Apex class 
public class productinfo{
    public string name;
    public double price;
    public integer quantity;

}
apex code


productinfo[] products =new productinfo[4];
productinfo p1= new productinfo();
p1.name='iphone';
p1.price=50000;
p1.quantity =2;
products[0]=p1; 
//system.debug('the name is'+ p1);
productinfo p2= new productinfo();
p2.name='sumsung';
p2.price=8888;
p2.quantity=9;
products[1]=p2;
//System.debug('the name of p2 '+p2);
productinfo p3=new productinfo();
p3.name='blackberry';
p3.price=3333;
p3.quantity=4;
products[2]=p3;
//system.debug('the details of p3 '+p3);

for(productinfo p :products)
{
    system.debug(p.name);
    system.debug(p.quantity);
    system.debug(p.price);
}
 
public class Dog 
{
   private String name;
    private Integer age;
    
    public void setName(String n)
    {
      name=n;  
    }
    public void SetAge(integer j)
    {
        age=j;
    }
    public String getName()
    {
        return name;
    }
    
    public Integer getAge()
    {
        return age;
    }
    public void bark ()
    {
        
        
        System.debug('');
    }
    

}
///
I am using this apex code 
Dog d1=new Dog();
d1.setName=('frido');
d1.setAge=12;
System.debug('the name is '+d1.getName() +'' +d1.getAge());