function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shruthi GM 4Shruthi GM 4 

How to get related Calls and Opportunities based on the Particular Contact

I need to display Calls and Opportunities based on the selection of Contact.
Do I need to write wrapper class?
Please help me.
Pankaj_GanwaniPankaj_Ganwani
Hi Shruti,

There are various ways through which you can achieve this.

1. Create the following template of wrapper class, declare the list of this type and bind it with the page:

public class SobjectWrapper
{
     public Sobject objSobj;
     public String sobjname;
}

2. You can create 3 separate lists to hold the related object records such as List<Task>, List<Event> and List<Opportunity>.

Thanks,
Pankaj
Shruthi GM 4Shruthi GM 4
Hi Pankaj,
I have started writing Wrapper class for opportunity but am facing an error!
Error: Compile Error: line 4:0 no viable alternative at character '​'

/*Class*/

public class OpportunityWrapper{
public String Opportunityname{get;set;} ----->here am facing the error!!!!!
public Decimal Amount{get; set;}
public String Stage{get; set;}
public Date Closedate{get; set;}

}
Please help.
 
Pankaj_GanwaniPankaj_Ganwani
Can you please paste the complete outer class?
Shruthi GM 4Shruthi GM 4
Outer class I have not yet started!!..I resolved this error somehow...but now how to get related opportunities and Calls on the click of Contacts on the page?
How do I write the logic?
Can you please help?