• Manjusrinu
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 14
    Replies

Hi All,

I am iterating quote records ,

Now when the first quote record comes into loops ,i should get the associated prdouct price  which is linked to oppournity 

Can anyone help me how to query ?..

for(Quote eachQuote : oppournityQuotes) {
            if(eachQuote.Account.BillingState == 'Telangana'  && eachQuote.Oppournity.product2.listprice  ) {
}   

Hi ,

If someone visited my website for the first time ,i should know about the actions performed by the visitor using pardot .

if the same visitor visits for the second time i should know what he/she has done on the website using pardot 

Can anyone help ?..

Hi ,

I am trying to prevent duplicate email and at the same time i am updating count field on lead when i give the same email ..

The count should update on the existing email lead record .I am getting count updated value in debug logs,but on the record .

Can anyone help me out ?..

Trigger :

trigger LeadTrigger on Lead (before insert, before update) {
    if(trigger.isInsert || trigger.isUpdate) { 
    Leaddupliacateemailpreventor dupEmail = new Leaddupliacateemailpreventor();
    dupEmail.duplicateEmail(trigger.new);
    }
    }
    
Helper class :
public class Leaddupliacateemailpreventor {
    public void duplicateEmail (List<Lead> Records) {
        Map<string,Lead> leadRecords = new Map<string,Lead>();
        List<Lead> myLeads = new List<Lead>();
        myLeads = [SELECT id,Email ,Email_count__c from Lead where Email != null];
        for(Lead ll :myLeads) {
            if(!(leadRecords.containsKey(ll.Email))) {
                leadRecords.put(ll.Email ,ll); 
            }
        }
        system.debug('ssssssssssss' + leadRecords.keySet());
        for(Lead newRecord : Records) {
            if(leadRecords.ContainsKey(newRecord.Email)) { 
                newRecord.Email.addError('Email exists'); 
                if( leadRecords.get(newRecord.Email).Email_count__c != null ) {
                    leadRecords.get(newRecord.Email).Email_count__c = leadRecords.get(newRecord.Email).Email_count__c +1;
                } 
                else {
                    leadRecords.get(newRecord.Email).Email_count__c = 1;
                }
            } 
            System.debug('hhhhhh   ' + leadRecords.get(newRecord.Email).Email_count__c );
        } 
    }
}

Hi ,
I have custom object called Campaignaccount__c ,with lokkup related to account called(Related account) ,when i creating new Record ,if account doesnt have oppournities with the related Campaigaccount record it should create a new oppournity record with the camapignaccount Record name , I nedd to perform this with bulk insertions .
I have the following code for only one Record and its working fine .
Can anyone help me how to perform this for bulk records  ?



Helper class : 
public class CampaignaccountTriggerhelper {
    string accountName ;
    public void insertUpdateRecords (List<Campaignaccount__c> campaignRecords ) {
        set<Id> camapignAccounts = new set<Id>();
        for(Campaignaccount__c cmp  : campaignRecords) {
            if(cmp.RelatedAccount__c != null) {
                accountName = cmp.Name;                
                camapignAccounts.add(cmp.RelatedAccount__c);
            } 
        }
        List<Opportunity> oppRecords = new List<Opportunity>([select Name,    Campaigncount__c,
                                                              AccountId from Opportunity
                                                              where AccountId in :camapignAccounts AND 
                                                              Name =: accountName  ] );
        if(oppRecords.size() >0 ) {
            for(Opportunity opp : oppRecords ) {
                 opp.Campaigncount__c = 0;
                opp.Campaigncount__c = opp.Campaigncount__c + 1; 
            }
update oppRecords ;
        } 
        if(oppRecords.size() == 0) {
            Opportunity a = new Opportunity(
                Name=accountName ,
                Campaigncount__c = 0,
                CloseDate = system.today() ,
                StageName = 'Closed Lost');
                 insert a;
        }   
    }  
}


Trigger :
Trigger CampaignaccountTrigger on Campaignaccount__c (after insert) {
CampaignaccountTriggerhelper myCamp = new CampaignaccountTriggerhelper();
    myCamp.insertUpdateRecords (Trigger.New); 

Hi,

I have a senario where i need to display phone field on vf page when Leadsource in contact is equal to "other" .I am perfect with page and controller and functionality is working gd .But when comming to test class it is not covering boolean variable . i,e the below highlited line is not covering ...

Can anyone please check it out ?

controller class :

public class ActionFunctionExample {
    public Contact  con{get;set;}
    public Boolean phone{get;set;}
    public ActionFunctionExample() {
        con=new Contact (); 
    }
    public pagereference clickandchange() {
        if(con.LeadSource=='Other') {
           phone=true; 
        }
        else{
            phone= false;
        }
        return null;
    }
}.

Test class :

@istest
public class ActionFunctiontest_TC {
    public static testmethod void testForActiofunction() {
        contact mycon = new contact();
        mycon.LastName='raghu';
        mycon.LeadSource = 'Other';
        mycon.HomePhone= '2483742';
        insert mycon ; 
        ActionFunctionExample ac = new ActionFunctionExample();
        ac.clickandchange();
        
    }
}

Hi i have a senario where i should write a batch class to add oppournities whose stage is need analysis and type is new oppournity and Age of oppurnity__c should be greater than 15 days ,My functionality is working fine but test class is not getting code coverage 100 percentage 

So can anyone helpme to find out the problem 

Batch class :

global class Batchforaddingoppournitytoaccount implements Database.Batchable<sobject>{
    global Database.QueryLocator start(Database.BatchableContext BC){
        string oppRecords = 'SELECT id, Name, StageName, Type, Age_of_oppournity__c FROM Opportunity';
        return Database.getQueryLocator(oppRecords);
    }
    global void execute(Database.BatchableContext BC , List<Opportunity> oppList){
        string addingRecords = Label.Account_Record; // holding my account id in custom label//
        List<Opportunity> oppournityListupdate = new List<Opportunity>(); 
        for(Opportunity eachoppournity : oppList){
            if(eachoppournity.Type == 'New Opportunity' && eachoppournity.StageName == 'Needs Analysis' && 
               eachoppournity.Age_of_oppournity__c >= 15){ 
                eachoppournity.AccountId = addingRecords;
                oppournityListupdate.add(eachoppournity);
            } 
        }
        if(oppournityListupdate.size() > 0){
            update oppournityListupdate;
        }
    }
    global void finish(DataBase.BatchableContext BC){ 
        
    }
}

 

Test Class :

@isTest
public class Testforbatchoppournityrecords_TC {
    public  static testMethod void oppournityRecordstest(){
        string accountRecordid = Label.Account_Record;
        List<Opportunity> updatingOppournities = new List<Opportunity>();
        Opportunity opp = new Opportunity ();
        opp.Name= 'smart mobiles';  
        opp.Type ='New Business';
        opp.StageName = 'Needs Analysis'; 
        opp.CloseDate=date.today().addMonths(3);
        insert opp;
        test.startTest();
        Batchforaddingoppournitytoaccount b = new Batchforaddingoppournitytoaccount();
        DataBase.executeBatch(b); 
        test.stopTest();
    }
}

Hi i have a senario where
1. if contact email is already existed , while inserting or updating the contact  ,it should throw an error (Email already exists with the name ) 
2. if i change the contact owner ,the related account owner should also be changed .

I have written the following code and working fine , but every time Email error is throwing for me ,even if i change the owner of contact record. 

Trigger : 

trigger Contacttrigger on Contact (before insert,before update ,after update) {
    Contacttriggerhandler helper = new Contacttriggerhandler(); 
        if(trigger.isBefore) {
            if(trigger.isInsert || trigger.isUpdate) {
            helper.checkEmailfields(trigger.new);
            }  
        } 
   if(trigger.isAfter){
    if(trigger.isUpdate){
            helper.changeOwner(trigger.new);             
        }
    } 
}

Handler class :

public class Contacttriggerhandler {
    public void checkEmailfields(List<contact> contactEmailchecks){
        List<contact> contactEmails =  new list<contact>();
        contactEmails = [select email from contact];
        for(contact con :contactEmailchecks ){
            for(contact exconmail : contactEmails){
                if(con.Email == exconmail.Email){ 
                    con.Email.addError('email already exists with the given email id');
                }
            }
        }
public void changeOwner( List<contact>  contactRecords){
        set<Id> contactRelatedaccount = new set<Id>();
        List<Account> accountUpdate = new List<Account>();
        string contactOwner; 
        for(contact con : contactRecords){
            if(con.AccountId != null){
                contactOwner = con.ownerId;
                contactRelatedaccount.add(con.AccountId);
            }
        }
        for(Account linkedAccount : [select id from Account where id in : contactRelatedaccount]){
            linkedaccount.ownerId = contactOwner;
            accountUpdate.add(linkedAccount);
        } 
        update accountUpdate;
    }
    } 

 

Hi,
I need to change the owner of account Records (Mannually)

when I manually change the record owner ,owner field is not getting changed , I think Account Name Having some hierarchy issue, so i am not able to change the record. Can anyone suggest me how to remove the Hierarchy option ?  Orelse why my account owner is not getting changed . Check the below image ( why i am getting this view hierarchy option )

Hi ,

I have a senario in which 2 users are in same profile,I have enabled one visual force page in the profile level

My second user should not have the access permision in-order to view the vf page  where as my first user can have the permission to view the vf page.
If my second user clicks on preview an error message should be shown him(You have no access to view the page)

Can anyone suggest me to solve the problem without using permission sets ??

Hi,
I have created a custom tab that needs to be posted on vf page,I am getting the output but not in the correct way  
The below is my code 

Can anyone help me to solve the issue ?

<apex:tabPanel switchType="client" >
        <apex:tab label="Home">Home content</apex:tab>
        <apex:tab label="Contacts">Contacts content</apex:tab>
        <apex:tab label="Achievements">Achievements content</apex:tab>
    </apex:tabPanel>

I am not getting the default stylings of the custom tabs

The image shows my output for the above code

Hi ,
i have a task that when my vf page gets loads i should dispaly accounts and when i click on show contcats button ,the related contacts should dispaly and when i click on show oppournity ,the related oppournities should be displayed .
I wrote the following code and i have no problem on dispalying accounts and contacts.
when i click on show opppournities it is dispalying url doesnt exist
Can anyone help me to figure it out ??
VF-PAGE:
<apex:page controller="AccountContactOppournitydisplay" action="{!getContacts}">
  <apex:form >
      <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfAccounts}" var="r">
            <apex:column value="{!r.Name}"/>
            <apex:column value="{!r.Rating}"/>
        </apex:pageBlockTable>
          <apex:commandButton value="Show contacts" action="/apex//clickactiondisplayContact"/>
        </apex:pageBlock>
   </apex:form>
</apex:page>

CLASS:

public class AccountContactOppournitydisplay
{
 public list<Account>listOfAccounts{get;set;}
 public list<Contact>listOfContacts{get;set;}
 public list<Opportunity>listOfoppournities{get;set;}
  
 public AccountContactOppournitydisplay()
 {
     try
      {
         listOfAccounts=new list<Account>();
        listOfAccounts=[select id,Name,Rating from Account order by Name limit 5];
        system.debug('list of accounts'+listOfAccounts);
       }catch(NullPointerException e)
         {system.debug('null exception');}
  }
      public void  getContacts()
        {
         try{
            listOfContacts=new list<Contact>();
            listOfContacts=[select id,Name from contact where AccountId IN :listOfAccounts];
            system.debug('contactlists'+listOfContacts);
          }
            catch(NullpointerException e)
            {system.debug('Exception raised');}
            }
    
        public void getOppournities()
        {
            try{
          listOfoppournities=new list<Opportunity>();
          listOfoppournities=[select id,Name from Opportunity where account.id IN:listOfAccounts limit 5];
            system.debug('oppournities '+listOfoppournities);
        }
            catch(nullpointerexception e)
            {
                system.debug('Exception raised');
            }
        }
   
}


VF PAGE 2: DISPLAYS CONTACTS

<apex:page controller="AccountContactOppournitydisplay" action="{!getcontacts}" >
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfcontacts}" var="a">
            <apex:column value="{!a.Name}"/>
              <apex:column value="{!a.id}"/>
        </apex:pageBlockTable>
        <apex:commandButton value="Show oppournities" action="/apex//clickactiondisplayOppournity"/>
       </apex:pageBlock>
    </apex:form>
</apex:page>


VF-PAGE3:
<apex:page controller="AccountContactOppournitydisplay" action="{!getOppournities}" >
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfoppournities}" var="k">
            <apex:column value="{!k.Name}"/>
              <apex:column value="{!k.id}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

ERROR:URL DOES NO LONGER EXIST (ONLY WHEN I CLICK ON SHOW OPPOURNITIES"
Hi,
I have a custom field called Type of picklist (picklist values are same as off type values on account object).
I need to get all the contacts related to account and auto update the Type field on contact object with a value same as off to that account..

I tried the following code ,it is not showing any errors but my field on contact is not updating.

Can anyone hlepme to solve the issue ?
Apex Class:
public class UpdatingtypefieldonContact {
    public Map<list<Account>,list<Contact>> maplist{get;set;}// getting list of id(accounts) and values(contacts) //
    list<Contact> updatedlist{get;set;}
    public void updatetypefield()
    {
      maplist=new Map<list<Account>,list<Contact>>();
       list<Account> accountlist=new list<Account>();
       list<Contact> contactlist=new list<Contact>();
       list<Contact> updatedlist=new list<Contact>(); // list after updating type field//
       accountlist=[select id,name,Type from Account];
         contactlist=[select id,name,Accountid,Type__c from Contact where Accountid in:accountlist]; 
        maplist.put(accountlist,contactlist);
       // system.debug(maplist);//
           for(Account aa:accountlist)
           {
          for(Contact cc:contactlist)
          {
            if(cc.Type__c=='null')
             {
                  cc.Type__c=aa.Type;
                 updatedlist.add(cc);
              }
          }
        }
        update updatedlist;
        maplist.put(accountlist,updatedlist);
        system.debug(maplist);
     }
}

 
Hi,
I need to insert a record into account object by using lists.
I tried the following code but it is not working 
Can anyone help me to solve out the problem ?

Apex-class:
public class Listaccounts 
{
  public static  void accounts()
   {
    List<Account> myList = new List<Account>(); 
    Account a = new Account(Name='ramana'); 
    myList.add(a);                    
    }
}

Vf-page:
<apex:page Controller=" Listaccounts ">
</apex:page>
Hi
I need a test class for the below requirement 

At the time of contact insertion/updation, check with the email field, if email already exist in database then throw an error .
my Trigger name:contactDuplicatePreventer

Hi All,

I need to have a test class for the below requirement 

.Display list of accounts in a block with checkbox, if the user selects the accounts and click on "show selected Account " button the accounts should display in the pageBlocktable beside the accounts list block
My visaul force page is ready with me ,can anyone help me how to write test class for the above problem ?

Hi All,

I need to have a test class for the below task

At the time of contact insertion/updation, check with the email field, if email already exist in database then throw an error.

Can anyone help me how to figure out that ?

Hi,
I need to dispaly an apex:message in my center of my vf page 
how can i do that ?
Hi,
I need to insert a new record usimg apex class ,I wrote the following code ,,but i couldnt remove the errors.Can you please help me ??User-added image
Hi,
I have a custom field called Type of picklist (picklist values are same as off type values on account object).
I need to get all the contacts related to account and auto update the Type field on contact object with a value same as off to that account..

I tried the following code ,it is not showing any errors but my field on contact is not updating.

Can anyone hlepme to solve the issue ?
Apex Class:
public class UpdatingtypefieldonContact {
    public Map<list<Account>,list<Contact>> maplist{get;set;}// getting list of id(accounts) and values(contacts) //
    list<Contact> updatedlist{get;set;}
    public void updatetypefield()
    {
      maplist=new Map<list<Account>,list<Contact>>();
       list<Account> accountlist=new list<Account>();
       list<Contact> contactlist=new list<Contact>();
       list<Contact> updatedlist=new list<Contact>(); // list after updating type field//
       accountlist=[select id,name,Type from Account];
         contactlist=[select id,name,Accountid,Type__c from Contact where Accountid in:accountlist]; 
        maplist.put(accountlist,contactlist);
       // system.debug(maplist);//
           for(Account aa:accountlist)
           {
          for(Contact cc:contactlist)
          {
            if(cc.Type__c=='null')
             {
                  cc.Type__c=aa.Type;
                 updatedlist.add(cc);
              }
          }
        }
        update updatedlist;
        maplist.put(accountlist,updatedlist);
        system.debug(maplist);
     }
}

 

Hi ,

I am trying to prevent duplicate email and at the same time i am updating count field on lead when i give the same email ..

The count should update on the existing email lead record .I am getting count updated value in debug logs,but on the record .

Can anyone help me out ?..

Trigger :

trigger LeadTrigger on Lead (before insert, before update) {
    if(trigger.isInsert || trigger.isUpdate) { 
    Leaddupliacateemailpreventor dupEmail = new Leaddupliacateemailpreventor();
    dupEmail.duplicateEmail(trigger.new);
    }
    }
    
Helper class :
public class Leaddupliacateemailpreventor {
    public void duplicateEmail (List<Lead> Records) {
        Map<string,Lead> leadRecords = new Map<string,Lead>();
        List<Lead> myLeads = new List<Lead>();
        myLeads = [SELECT id,Email ,Email_count__c from Lead where Email != null];
        for(Lead ll :myLeads) {
            if(!(leadRecords.containsKey(ll.Email))) {
                leadRecords.put(ll.Email ,ll); 
            }
        }
        system.debug('ssssssssssss' + leadRecords.keySet());
        for(Lead newRecord : Records) {
            if(leadRecords.ContainsKey(newRecord.Email)) { 
                newRecord.Email.addError('Email exists'); 
                if( leadRecords.get(newRecord.Email).Email_count__c != null ) {
                    leadRecords.get(newRecord.Email).Email_count__c = leadRecords.get(newRecord.Email).Email_count__c +1;
                } 
                else {
                    leadRecords.get(newRecord.Email).Email_count__c = 1;
                }
            } 
            System.debug('hhhhhh   ' + leadRecords.get(newRecord.Email).Email_count__c );
        } 
    }
}

Hi ,
I have custom object called Campaignaccount__c ,with lokkup related to account called(Related account) ,when i creating new Record ,if account doesnt have oppournities with the related Campaigaccount record it should create a new oppournity record with the camapignaccount Record name , I nedd to perform this with bulk insertions .
I have the following code for only one Record and its working fine .
Can anyone help me how to perform this for bulk records  ?



Helper class : 
public class CampaignaccountTriggerhelper {
    string accountName ;
    public void insertUpdateRecords (List<Campaignaccount__c> campaignRecords ) {
        set<Id> camapignAccounts = new set<Id>();
        for(Campaignaccount__c cmp  : campaignRecords) {
            if(cmp.RelatedAccount__c != null) {
                accountName = cmp.Name;                
                camapignAccounts.add(cmp.RelatedAccount__c);
            } 
        }
        List<Opportunity> oppRecords = new List<Opportunity>([select Name,    Campaigncount__c,
                                                              AccountId from Opportunity
                                                              where AccountId in :camapignAccounts AND 
                                                              Name =: accountName  ] );
        if(oppRecords.size() >0 ) {
            for(Opportunity opp : oppRecords ) {
                 opp.Campaigncount__c = 0;
                opp.Campaigncount__c = opp.Campaigncount__c + 1; 
            }
update oppRecords ;
        } 
        if(oppRecords.size() == 0) {
            Opportunity a = new Opportunity(
                Name=accountName ,
                Campaigncount__c = 0,
                CloseDate = system.today() ,
                StageName = 'Closed Lost');
                 insert a;
        }   
    }  
}


Trigger :
Trigger CampaignaccountTrigger on Campaignaccount__c (after insert) {
CampaignaccountTriggerhelper myCamp = new CampaignaccountTriggerhelper();
    myCamp.insertUpdateRecords (Trigger.New); 

Hi i have a senario where i should write a batch class to add oppournities whose stage is need analysis and type is new oppournity and Age of oppurnity__c should be greater than 15 days ,My functionality is working fine but test class is not getting code coverage 100 percentage 

So can anyone helpme to find out the problem 

Batch class :

global class Batchforaddingoppournitytoaccount implements Database.Batchable<sobject>{
    global Database.QueryLocator start(Database.BatchableContext BC){
        string oppRecords = 'SELECT id, Name, StageName, Type, Age_of_oppournity__c FROM Opportunity';
        return Database.getQueryLocator(oppRecords);
    }
    global void execute(Database.BatchableContext BC , List<Opportunity> oppList){
        string addingRecords = Label.Account_Record; // holding my account id in custom label//
        List<Opportunity> oppournityListupdate = new List<Opportunity>(); 
        for(Opportunity eachoppournity : oppList){
            if(eachoppournity.Type == 'New Opportunity' && eachoppournity.StageName == 'Needs Analysis' && 
               eachoppournity.Age_of_oppournity__c >= 15){ 
                eachoppournity.AccountId = addingRecords;
                oppournityListupdate.add(eachoppournity);
            } 
        }
        if(oppournityListupdate.size() > 0){
            update oppournityListupdate;
        }
    }
    global void finish(DataBase.BatchableContext BC){ 
        
    }
}

 

Test Class :

@isTest
public class Testforbatchoppournityrecords_TC {
    public  static testMethod void oppournityRecordstest(){
        string accountRecordid = Label.Account_Record;
        List<Opportunity> updatingOppournities = new List<Opportunity>();
        Opportunity opp = new Opportunity ();
        opp.Name= 'smart mobiles';  
        opp.Type ='New Business';
        opp.StageName = 'Needs Analysis'; 
        opp.CloseDate=date.today().addMonths(3);
        insert opp;
        test.startTest();
        Batchforaddingoppournitytoaccount b = new Batchforaddingoppournitytoaccount();
        DataBase.executeBatch(b); 
        test.stopTest();
    }
}

Hi i have a senario where
1. if contact email is already existed , while inserting or updating the contact  ,it should throw an error (Email already exists with the name ) 
2. if i change the contact owner ,the related account owner should also be changed .

I have written the following code and working fine , but every time Email error is throwing for me ,even if i change the owner of contact record. 

Trigger : 

trigger Contacttrigger on Contact (before insert,before update ,after update) {
    Contacttriggerhandler helper = new Contacttriggerhandler(); 
        if(trigger.isBefore) {
            if(trigger.isInsert || trigger.isUpdate) {
            helper.checkEmailfields(trigger.new);
            }  
        } 
   if(trigger.isAfter){
    if(trigger.isUpdate){
            helper.changeOwner(trigger.new);             
        }
    } 
}

Handler class :

public class Contacttriggerhandler {
    public void checkEmailfields(List<contact> contactEmailchecks){
        List<contact> contactEmails =  new list<contact>();
        contactEmails = [select email from contact];
        for(contact con :contactEmailchecks ){
            for(contact exconmail : contactEmails){
                if(con.Email == exconmail.Email){ 
                    con.Email.addError('email already exists with the given email id');
                }
            }
        }
public void changeOwner( List<contact>  contactRecords){
        set<Id> contactRelatedaccount = new set<Id>();
        List<Account> accountUpdate = new List<Account>();
        string contactOwner; 
        for(contact con : contactRecords){
            if(con.AccountId != null){
                contactOwner = con.ownerId;
                contactRelatedaccount.add(con.AccountId);
            }
        }
        for(Account linkedAccount : [select id from Account where id in : contactRelatedaccount]){
            linkedaccount.ownerId = contactOwner;
            accountUpdate.add(linkedAccount);
        } 
        update accountUpdate;
    }
    } 

 

Hi,
I have created a custom tab that needs to be posted on vf page,I am getting the output but not in the correct way  
The below is my code 

Can anyone help me to solve the issue ?

<apex:tabPanel switchType="client" >
        <apex:tab label="Home">Home content</apex:tab>
        <apex:tab label="Contacts">Contacts content</apex:tab>
        <apex:tab label="Achievements">Achievements content</apex:tab>
    </apex:tabPanel>

I am not getting the default stylings of the custom tabs

The image shows my output for the above code

Hi ,
i have a task that when my vf page gets loads i should dispaly accounts and when i click on show contcats button ,the related contacts should dispaly and when i click on show oppournity ,the related oppournities should be displayed .
I wrote the following code and i have no problem on dispalying accounts and contacts.
when i click on show opppournities it is dispalying url doesnt exist
Can anyone help me to figure it out ??
VF-PAGE:
<apex:page controller="AccountContactOppournitydisplay" action="{!getContacts}">
  <apex:form >
      <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfAccounts}" var="r">
            <apex:column value="{!r.Name}"/>
            <apex:column value="{!r.Rating}"/>
        </apex:pageBlockTable>
          <apex:commandButton value="Show contacts" action="/apex//clickactiondisplayContact"/>
        </apex:pageBlock>
   </apex:form>
</apex:page>

CLASS:

public class AccountContactOppournitydisplay
{
 public list<Account>listOfAccounts{get;set;}
 public list<Contact>listOfContacts{get;set;}
 public list<Opportunity>listOfoppournities{get;set;}
  
 public AccountContactOppournitydisplay()
 {
     try
      {
         listOfAccounts=new list<Account>();
        listOfAccounts=[select id,Name,Rating from Account order by Name limit 5];
        system.debug('list of accounts'+listOfAccounts);
       }catch(NullPointerException e)
         {system.debug('null exception');}
  }
      public void  getContacts()
        {
         try{
            listOfContacts=new list<Contact>();
            listOfContacts=[select id,Name from contact where AccountId IN :listOfAccounts];
            system.debug('contactlists'+listOfContacts);
          }
            catch(NullpointerException e)
            {system.debug('Exception raised');}
            }
    
        public void getOppournities()
        {
            try{
          listOfoppournities=new list<Opportunity>();
          listOfoppournities=[select id,Name from Opportunity where account.id IN:listOfAccounts limit 5];
            system.debug('oppournities '+listOfoppournities);
        }
            catch(nullpointerexception e)
            {
                system.debug('Exception raised');
            }
        }
   
}


VF PAGE 2: DISPLAYS CONTACTS

<apex:page controller="AccountContactOppournitydisplay" action="{!getcontacts}" >
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfcontacts}" var="a">
            <apex:column value="{!a.Name}"/>
              <apex:column value="{!a.id}"/>
        </apex:pageBlockTable>
        <apex:commandButton value="Show oppournities" action="/apex//clickactiondisplayOppournity"/>
       </apex:pageBlock>
    </apex:form>
</apex:page>


VF-PAGE3:
<apex:page controller="AccountContactOppournitydisplay" action="{!getOppournities}" >
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!listOfoppournities}" var="k">
            <apex:column value="{!k.Name}"/>
              <apex:column value="{!k.id}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

ERROR:URL DOES NO LONGER EXIST (ONLY WHEN I CLICK ON SHOW OPPOURNITIES"
Hi,
I need to insert a record into account object by using lists.
I tried the following code but it is not working 
Can anyone help me to solve out the problem ?

Apex-class:
public class Listaccounts 
{
  public static  void accounts()
   {
    List<Account> myList = new List<Account>(); 
    Account a = new Account(Name='ramana'); 
    myList.add(a);                    
    }
}

Vf-page:
<apex:page Controller=" Listaccounts ">
</apex:page>
Hi
I need a test class for the below requirement 

At the time of contact insertion/updation, check with the email field, if email already exist in database then throw an error .
my Trigger name:contactDuplicatePreventer
Hi,
I need to dispaly an apex:message in my center of my vf page 
how can i do that ?
Hello,

I am facing issue in Trailhead : Queueable Apex
https://trailhead.salesforce.com/asynchronous_apex/async_apex_queueable

We have to write a class and test class for 100% code coverage.
But on Validating, I am getting error: 

Challenge Not yet complete... here's what's wrong: 
The 'AddPrimaryContactTest' test class doesn't appear to be using the 'AddPrimaryContact' class.


He are  my classes:
global class AddPrimaryContact implements Queueable {
    
    private Contact queueContact;
    private String contactState;
    
    public AddPrimaryContact(){}
    
    public AddPrimaryContact(Contact con, String state){
        queueContact = con;
        contactState = state;
    }
    
    public void execute(QueueableContext context){
        
        List<Account> accList = [select id,name from Account  where BillingState =: contactState limit 200];
        List<Contact>conList = new List<Contact>();
        for(account acl : accList){
            Contact cont = queueContact.clone(false);
            cont.AccountId=acl.id;
            conList.add(cont);
        }
        insert conList;
        
    }
}

Test class:
@isTest
public class AddPrimaryContactTest {
    
    @testSetup
    public static void setup(){
        
        List<Account> accList = new List<Account>();
        for(integer ing =0;ing<50; ing++){
            Account acc = new Account(Name='TEst Acc',BillingState ='NY');
            accList.add(acc);
        }    
        
        for(integer ing =0;ing<50; ing++){
            Account acc = new Account(Name='TEst Acc',BillingState ='CA');
            accList.add(acc);
        } 
        
        insert accList;
        
        Contact con = new Contact(LastName='TestContact');
        insert con;
    }
    
   static testmethod  void testAcount(){
        
        contact con = [select id,name,AccountId from contact where name='TestContact'];
         Test.startTest();
         
        AddPrimaryContact ad = new AddPrimaryContact ();
        AddPrimaryContact updater = new AddPrimaryContact (con, 'CA');
        // startTest/stopTest block to force async processes to run
               System.enqueueJob(ad);
        ID jobID = System.enqueueJob(updater);
        Test.stopTest();       
        
    }
}
I am getting 100% code coverage for my class.
I need to Query the Last notes and attachments that was added in a Quote, into a PDF, I dont now how to query that , any suggestions?
Hello All,
I have completed this challenge.

1-For this first you need to create a helper formula field(type-percent) 
Percent Completed :
(DATEVALUE( CreatedDate ) - CloseDate )/100


2- Then you need to create the actual formula field (type- text) by using the helper formula field.
Opportunity Progress :

IF( Percent_Completed__c <=25,"Early", 
IF(Percent_Completed__c <=75,"Middle", 
"Late"))

Thanks,
Nida



 
I need to move the text to right side by certain points on visualforce page:
<apex:outputText >At least one Reason is required</apex:outputText>
<apex:outputText >Use Ctrl+Click to select more than One Reason</apex:outputText> 

 

How can i set the defalut value for phone field?

 

I tried following options

1) 000-000-0000

2) (000)-000-0000

 

but i am getting the error.

 

Error: Formula result is data type (Number), incompatible with expected data type (Phone)