You need to sign in to do that
Don't have an account?

Incompatible types ...
Hi All,
Compile Error: Incompatible types since an instance of LIST<SObject> is never an instance of LIST<objectList.PieWedgeData>
Our Code is :-
public List<PieWedgeData> getPieData() {
data = (List<PieWedgeData>)mynewinst; // mynewinst is a list of SObject type
data.addall(mynewinst);
return data;
}
// Wrapper class
public class PieWedgeData {
public String name { get; set; }
public Integer data { get; set; }
public PieWedgeData(String name, Integer data) {
this.name = name;
this.data = data;
}
}
According to debug log "mynewinstance" contents :-
03:01:02.344 (344669000)|USER_DEBUG|[86]|DEBUG|$$$$$$$$$$$$$$$$$$mynewinst$$$$$$$$$$$$$$$$$$(Room__c:{White_Board__c=true, OwnerId=005900000017R4DAAU, LastModifiedDate=2012-11-26 09:10:34, Block__c=1, Phone_No__c=1234567890, Flip_Chart__c=true, No_of_Machines__c=2, SystemModstamp=2012-11-26 09:10:34, Email_Id__c=mayur.nagaonkar@lntinfotech.com, Location__c=Vashi, LastReferencedDate=2012-11-26 09:10:35, LastModifiedById=005900000017R4DAAU, Seating_Capacity__c=10, Screen__c=true, Name=R-00003, City__c=Mumbai, LastViewedDate=2012-11-26 09:10:35, Address__c=Shil Road,Mahape, Remarks__c=None, CreatedById=005900000017R4DAAU, CreatedDate=2012-11-26 09:10:34, Projector__c=true, IsDeleted=false, Id=a0K900000039mYcEAI, Type__c=Discussion Room, Co_ordinator_Name__c=xyz}, Room__c:{White_Board__c=true, OwnerId=005900000017R4DAAU, LastModifiedDate=2012-11-22 07:19:48, Block__c=1, Phone_No__c=1234567890, Flip_Chart__c=true, No_of_Machines__c=100, SystemModstamp=2012-11-22 07:19:48, Email_Id__c=mayur.nagaonkar@lntinfotech.com, Location__c=Vashi, LastReferencedDate=2012-11-26 11:44:10, LastModifiedById=005900000017R4DAAU, Seating_Capacity__c=100, Screen__c=true, Name=R-00001, City__c=Mumbai, LastViewedDate=2012-11-26 11:44:10, Address__c=Shil Road,Mahape, Remarks__c=None, CreatedById=005900000017R4DAAU, CreatedDate=2012-11-22 07:19:48, Projector__c=true, IsDeleted=false, Id=a0K900000039VaCEAU, Type__c=Technical Training Room, Co_ordinator_Name__c=xyz}, Room__c:{White_Board__c=true, OwnerId=005900000017R4DAAU, LastModifiedDate=2012-11-22 07:26:52, Block__c=1, Phone_No__c=1234569870, Flip_Chart__c=false, No_of_Machines__c=0, SystemModstamp=2012-11-22 07:26:52, Email_Id__c=gaurav.raj@lntinfotech.com, Location__c=Shivaji Nagar, LastReferencedDate=2012-11-22 07:26:53, LastModifiedById=005900000017R4DAAU, Seating_Capacity__c=50, Screen__c=true, Name=R-00002, City__c=Pune, LastViewedDate=2012-11-22 07:26:53, Address__c=Shivaji Nagar, Remarks__c=None, CreatedById=005900000017R4DAAU, CreatedDate=2012-11-22 07:26:52, Projector__c=true, IsDeleted=false, Id=a0K900000039VbPEAU, Type__c=Soft Skill Training Room, Co_ordinator_Name__c=abc})
Basic mistake
You cannot case a SOBJECT list to Custom Class.
You have to specifically assign the value and create a list of PieWedgeData
Hi,
The scenario is i am getting all my data in "mynewinstance" through
1.Selecting an Object from the list
2.Applying the Filter
3.Displaying the data in Pageblocktable
4.Display the Pageblocktable data in Charts.
So we have now reached till step 3 ,So now would like to know if it is possible to dynamically assign the data which is present in SObject type list i.e "mynewinstance " in wrapper class?
Hi,
public List<PieWedgeData> getPieData() {
for( Sobject sj : mynewinst ) { // iterate the 'mynewinst ' over for loop and add into the wrapper class one by one.
/* you need to add one String variable and one Integer value in wrapper list. So take value from each record like sj.name etc.*/
data.add( new PieWedgeData(sj.Name,sj.data));
}
return data;
}
Please let me know if u have any problem on same,and if this post helps u please give KUDOS by click on star at left
Hi Puja,
v
Hi,
please put your object name instead of 'Sobject' like account,contact etc..
And if the object name is dynamic then use Sobject and get field values as sj.get('name')
for( Sobject sj : mynewinst )
data.add( new PieWedgeData(sj.get('Name'),sj.get('data')));
And please put the correct fields name instead of 'Name' and 'data' which u want to add.
please let me know if u have any problem on same,and if this post helps u please give KUDOS by click on star at left.
hi Puja,
Now I have changed the following line in our Code as per your suggestion :-
Hi,
There is little mistake ,Please change it
data.add( new PieWedgeData(String,valueOf(sj.get('Name')),Integer.valueOf(sj.get('data'))));
it is very difficult for me to give any solution without knowing your requirement. you must need to add the particular field name. Again this code gives error because I think there is no field name 'data' in uor object.