• sampath palli
  • NEWBIE
  • 80 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 21
    Replies
Hai All

I have an requirement that when i enter account name in text box click on submit it display all the related contact records 
Please check my code

public class conbyacc {
    public String accname{set;get;}
    public list<Account> acclist{set;get;}
    public list<Contact> conlist{set;get;}
    public set<Account> accids{set;get;}
    public list<Contact> getcons(){
        acclist.clear();
        conlist.clear();
        accids.clear();
        acclist=[select Id,name from Account where name=:accname];
        for(Integer i=0; i<acclist.size(); i++){
            accids.add(acclist[i].Id);  // Getting Error
        }
        conlist=[select name,accountid from Contact where accountid IN:accids];
        return conlist;
        
    }

}


Thanks In Advance
Sampath Palli
Hi 

I have an requirement that i am tryong to insert Records in to  object after completing insertation operation i want to display reports in vf page 

For example i am inserted 200 records in to x object after completing operation i want to generate report on insertation of 200 records which are successfully inserted and which records failed to insert

Thanks In Advance
Sampath Palli
Hi 

I have an requirement when i am trying to insert account with same name which is alredy exists then it prevents the creation of duplicate record
I have written a code but i am getting error "Initial term of field expression must be a concrete SObject: List<Account>"

Please chech my code

trigger Tsen2 on Account (before insert,before update) {
    for(Account a:Trigger.new){
        list<Account> acc=[select id from Account where name=:a.Name and Rating=:a.Rating];
        if(acc.size()>0){
            acc.Name.addError('you cannot create duplicate values');
        }
    }

}

Thanks in Advance
Hi

Can any one suggest me project based real time scenario's in development which is on Triggers, SOQL , SOSL , Batch apex, Schedule apex and governing limits

Thanks In Advance
Sampath palli
Hi All
can you please share interview questions and different senarios which ask for experienced sfdc developers
 
Hi
I have writen a trigger for two custom objects like registration and rumexpenses and i given lookup relation between these two objects i have an requirement when the record created in registration object with field rum name then automatically new record is created in rumexpenses object also. to achive this i have writen a after insert trigger but it not working it fires error. please check my code

Apex class:

public class Rumapex {
    public String rumname{set;get;}
    public String password{set;get;}
    public String email{set;get;}
    public list<Registartion__c> result{set;get;}
    public pagereference register(){
        pageReference p=new pageReference('/apex/RegistrationPage_Rum');
        return p;
    }
    public pageReference go(){
        pageReference p=new pageReference('/apex/Home');
        return p;
    }
    public PageReference login(){
        pageReference p=new pageReference('/apex/loginpage_Rum');
        return p;
    }
    public pageReference forgetpwd(){
        pageReference p=new pageReference('/apex/forgetpwd_Rum');
        return p;
        }
    public pageReference search(){
        Integer regcount=[select count() from Registartion__c where Rum_Name__c=:rumname];
            if(regcount==0){
               return create(); 
            }else{
              Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.WARNING,'Records are already existed'));
                return null;
            }
        }
   public PageReference create(){
        Registartion__c r=new Registartion__c();
        r.Rum_Name__c=rumname;
        r.Password__c=password;
       r.E_Mail__c=email;
        insert r;
       PageReference p=new PageReference('/apex/loginpage_Rum');
       ApexPages.Message msg=new ApexPages.message(ApexPages.Severity.CONFIRM,'Registration completed successfully');
       ApexPages.addMessage(msg);
        return p;
    }
    public void clear(){
        rumname=null;
        password=null;
       email=null;
    }
    public pageReference getdetails(){
       result=[select Rum_Name__c,Password__c from Registartion__c where Rum_Name__c = :rumname and Password__c=:password];
          if(result.size()>0){
           return go(); 
        }
        else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Enter valid credentials'));
            return null;
        }
        }
    public void getpwd(){
        result=[select Rum_Name__c,Password__c,E_Mail__c from Registartion__c where E_Mail__c=:email];
        if(result.size()>0){
            rumname=result[0].Rum_Name__c;
            password=result[0].Password__c;
            email=result[0].E_Mail__c;
        }    
        else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Enter registred E-mail'));   
        }
      } 
    }

Trigger:

trigger RumnameTrigger on Registartion__c (after insert) {
    list<Rum_Expenses__c>exp=new list<Rum_Expenses__c>();
    for(Registartion__c reg:Trigger.new){
        Rum_Expenses__c ru=new Rum_Expenses__c();
        ru.Id=reg.Id;
        ru.Rum_Name__c=reg.Rum_Name__c;
        exp.add(ru);
     }
    insert exp;
}

when records are inserted through vf page it shoes error like this
User-added image
When records are inserted in sobject
User-added image

Thanks in Advance
Hi

I have an requirement that for example i have an application llike Rum expenses calculations then I am login with rum name once my login is completed I need to add members of that rum which i login and once i add the members one by one these members names are added in to pick list dynamically how i got this requirememt

And how i relate this rum name to all the members and other data like goods purchases and their amount

Thanks in Advance
Hi 
I have an requirement that i need to make different vf pages as tabs for example
i have created 4 vf pages with different components like input&output. I need to make these pages as tabs for a site

Thanks in Advance 
Hi 

I have an requirement that i need to display the records in vf page for example i forget my password i need to retrive my password by using mail id which are existed in custom object,If i entered the email id if this mail id exists it retrives the username and password, else it fires wrror message

Thanks in Advance
I have an requirement that i need to retrive both name and password data from sobjecct which are given in vf page . I have write a soql query in apex controller like this way but it is working please suggest me 
select Rum_Name__c,Password__c from Registartion__c where Rum_Name__c = :rname,Password__c=:pwd;

Thanks in advance

I have an requirement i need to verify details existing in sobject using SOQL for example that i have an custom object with fields name,password and i have vf page like login page. before login first i need to check weather the given name and password which are given in login page is existed in object or not,If details are existed then go to home page Else it show message enter valid details
Please go through my code:
apex code:

public class loginapex_Rum {
    public String rname{set;get;}
    public String pwd{set;get;}
    public list<Registartion__c>result{set;get;}
    public pagereference register(){
        pageReference p=new pageReference('/apex/RegistrationPage_Rum');
        return p;
    }
    public pageReference go(){
        pageReference p=new pageReference('/apex/Home');
        return p;
    }
 
    public void getdetails(){
        result=[select Rum_Name__c,Password__c from Registartion__c];
        for(Registartion__c r:result){
            if(r.Rum_Name__c==rname&&r.Password__c==pwd){
                go();
            }else{
                
            }
        }
    }

}


vf page:

<apex:page controller="loginapex_Rum">
    <apex:form >
    <apex:pageBlock title="Login" >
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem >
            <apex:outputLabel value="Enter Rum Name"/>
            <apex:inputText value="{!rname}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Enter Password" />
                <apex:inputSecret value="{!pwd}"/>
            </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
            <apex:commandButton value="Login" action="{!getdetails}"/>
            <apex:commandButton value="SignUp" action="{!register}"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockSection columns="2">
        <apex:pageBlockSectionItem >
            <nbsp></nbsp>
            <apex:commandLink value="Forget Password"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>
Hi
I have a requirement that i need to perform dynamic dml operations and when i have custom object registration and vf pages like login and registration And registration object with fields name,password,email.When i entered name dynamically in vf page if i entered name is existed in object it returns null if i entered name is doesn't exist in object then we need to insert the data and go to login page. 
Please check my code:
ApexClass
public class Registrationapex_Rum {
public String rumname{set;get;}
public String password{set;get;}
public String email{set;get;}
public list<Registartion__c> reg{set;get;}
public void search(){
reg=[select Rum_Name__c,Password__c,E_Mail__c from Registartion__c where Rum_Name__c=:rumname];
for(Registartion__c rl:reg){
if(rl.Rum_Name__c==rumname){
clear(); 
}else{
create();
}
}
}
public PageReference create(){
Registartion__c r=new Registartion__c();
r.Rum_Name__c=rumname;
r.Password__c=password;
r.E_Mail__c=email;
insert r;
PageReference p=new PageReference('/apex/loginpage_Rum');
return p;
}
public void clear(){
rumname=null;
password=null;
email=null;
}
}
VF Page:
<apex:page controller="Registrationapex_Rum">
<apex:form >
<apex:pageBlock title="Registration" id="pb1">
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Rum Name"/>
<apex:inputText value="{!rumname}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Password"/>
<apex:inputText value="{!password}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="E-mail"/>
<apex:inputText value="{!email}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton value="Submit" action="{!search}"/>
<apex:commandButton value="Clear" action="{!clear}" reRender="pb1"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks In Advance
Sampath
Hai All

I have an requirement that when i enter account name in text box click on submit it display all the related contact records 
Please check my code

public class conbyacc {
    public String accname{set;get;}
    public list<Account> acclist{set;get;}
    public list<Contact> conlist{set;get;}
    public set<Account> accids{set;get;}
    public list<Contact> getcons(){
        acclist.clear();
        conlist.clear();
        accids.clear();
        acclist=[select Id,name from Account where name=:accname];
        for(Integer i=0; i<acclist.size(); i++){
            accids.add(acclist[i].Id);  // Getting Error
        }
        conlist=[select name,accountid from Contact where accountid IN:accids];
        return conlist;
        
    }

}


Thanks In Advance
Sampath Palli
Hi 

I have an requirement when i am trying to insert account with same name which is alredy exists then it prevents the creation of duplicate record
I have written a code but i am getting error "Initial term of field expression must be a concrete SObject: List<Account>"

Please chech my code

trigger Tsen2 on Account (before insert,before update) {
    for(Account a:Trigger.new){
        list<Account> acc=[select id from Account where name=:a.Name and Rating=:a.Rating];
        if(acc.size()>0){
            acc.Name.addError('you cannot create duplicate values');
        }
    }

}

Thanks in Advance
Hi

Can any one suggest me project based real time scenario's in development which is on Triggers, SOQL , SOSL , Batch apex, Schedule apex and governing limits

Thanks In Advance
Sampath palli
Hi
I have writen a trigger for two custom objects like registration and rumexpenses and i given lookup relation between these two objects i have an requirement when the record created in registration object with field rum name then automatically new record is created in rumexpenses object also. to achive this i have writen a after insert trigger but it not working it fires error. please check my code

Apex class:

public class Rumapex {
    public String rumname{set;get;}
    public String password{set;get;}
    public String email{set;get;}
    public list<Registartion__c> result{set;get;}
    public pagereference register(){
        pageReference p=new pageReference('/apex/RegistrationPage_Rum');
        return p;
    }
    public pageReference go(){
        pageReference p=new pageReference('/apex/Home');
        return p;
    }
    public PageReference login(){
        pageReference p=new pageReference('/apex/loginpage_Rum');
        return p;
    }
    public pageReference forgetpwd(){
        pageReference p=new pageReference('/apex/forgetpwd_Rum');
        return p;
        }
    public pageReference search(){
        Integer regcount=[select count() from Registartion__c where Rum_Name__c=:rumname];
            if(regcount==0){
               return create(); 
            }else{
              Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.WARNING,'Records are already existed'));
                return null;
            }
        }
   public PageReference create(){
        Registartion__c r=new Registartion__c();
        r.Rum_Name__c=rumname;
        r.Password__c=password;
       r.E_Mail__c=email;
        insert r;
       PageReference p=new PageReference('/apex/loginpage_Rum');
       ApexPages.Message msg=new ApexPages.message(ApexPages.Severity.CONFIRM,'Registration completed successfully');
       ApexPages.addMessage(msg);
        return p;
    }
    public void clear(){
        rumname=null;
        password=null;
       email=null;
    }
    public pageReference getdetails(){
       result=[select Rum_Name__c,Password__c from Registartion__c where Rum_Name__c = :rumname and Password__c=:password];
          if(result.size()>0){
           return go(); 
        }
        else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Enter valid credentials'));
            return null;
        }
        }
    public void getpwd(){
        result=[select Rum_Name__c,Password__c,E_Mail__c from Registartion__c where E_Mail__c=:email];
        if(result.size()>0){
            rumname=result[0].Rum_Name__c;
            password=result[0].Password__c;
            email=result[0].E_Mail__c;
        }    
        else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Enter registred E-mail'));   
        }
      } 
    }

Trigger:

trigger RumnameTrigger on Registartion__c (after insert) {
    list<Rum_Expenses__c>exp=new list<Rum_Expenses__c>();
    for(Registartion__c reg:Trigger.new){
        Rum_Expenses__c ru=new Rum_Expenses__c();
        ru.Id=reg.Id;
        ru.Rum_Name__c=reg.Rum_Name__c;
        exp.add(ru);
     }
    insert exp;
}

when records are inserted through vf page it shoes error like this
User-added image
When records are inserted in sobject
User-added image

Thanks in Advance
Hi 

I have an requirement that i need to display the records in vf page for example i forget my password i need to retrive my password by using mail id which are existed in custom object,If i entered the email id if this mail id exists it retrives the username and password, else it fires wrror message

Thanks in Advance
I have an requirement that i need to retrive both name and password data from sobjecct which are given in vf page . I have write a soql query in apex controller like this way but it is working please suggest me 
select Rum_Name__c,Password__c from Registartion__c where Rum_Name__c = :rname,Password__c=:pwd;

Thanks in advance

I have an requirement i need to verify details existing in sobject using SOQL for example that i have an custom object with fields name,password and i have vf page like login page. before login first i need to check weather the given name and password which are given in login page is existed in object or not,If details are existed then go to home page Else it show message enter valid details
Please go through my code:
apex code:

public class loginapex_Rum {
    public String rname{set;get;}
    public String pwd{set;get;}
    public list<Registartion__c>result{set;get;}
    public pagereference register(){
        pageReference p=new pageReference('/apex/RegistrationPage_Rum');
        return p;
    }
    public pageReference go(){
        pageReference p=new pageReference('/apex/Home');
        return p;
    }
 
    public void getdetails(){
        result=[select Rum_Name__c,Password__c from Registartion__c];
        for(Registartion__c r:result){
            if(r.Rum_Name__c==rname&&r.Password__c==pwd){
                go();
            }else{
                
            }
        }
    }

}


vf page:

<apex:page controller="loginapex_Rum">
    <apex:form >
    <apex:pageBlock title="Login" >
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem >
            <apex:outputLabel value="Enter Rum Name"/>
            <apex:inputText value="{!rname}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Enter Password" />
                <apex:inputSecret value="{!pwd}"/>
            </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
            <apex:commandButton value="Login" action="{!getdetails}"/>
            <apex:commandButton value="SignUp" action="{!register}"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockSection columns="2">
        <apex:pageBlockSectionItem >
            <nbsp></nbsp>
            <apex:commandLink value="Forget Password"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>