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

ave error: Illegal assignment from Schema.SObjectField to Decimal
I receive the following compile error : Description Resource Path Location Type
Save error: Illegal assignment from Schema.SObjectField to Decimal ContactChanges.trigger EAR AFTER REFRESH 3_05_2014/src/triggers line 520 Force.com save problem
Any and all help greatly appreciated!
Code below:
List<Quintile__c> q = [Select Quintile__c, T12_Min__c, T12_Max__c,Los_Min__c,LOS_Max__c,Start_Date__c,End_Date__c
from Quintile__c
where start_date__c <= today and end_date__c > today];
if(!q.isEmpty()){
if (c.Total_years_as_a_rep__c != 0 && c.Total_years_as_a_rep__c != null && c.Estimated_T_12__c != 0 && c.Estimated_T_12__c != null &&
c.Estimated_T_12__c >= Quintile__c.T12_Min__c &&
c.Estimated_T_12__c < Quintile__c.T12_Max__c &&
c.Total_years_as_a_rep__c >= Quintile__c.LOS_Min__c &&
c.Total_years_as_a_rep__c < Quintile__c.LOS_Max__c
){
c.Estimated_Quintile__c = Quintile__c.Quintile__c;
}
}else
{
//handler code for no matching account
}
Save error: Illegal assignment from Schema.SObjectField to Decimal ContactChanges.trigger EAR AFTER REFRESH 3_05_2014/src/triggers line 520 Force.com save problem
Any and all help greatly appreciated!
Code below:
List<Quintile__c> q = [Select Quintile__c, T12_Min__c, T12_Max__c,Los_Min__c,LOS_Max__c,Start_Date__c,End_Date__c
from Quintile__c
where start_date__c <= today and end_date__c > today];
if(!q.isEmpty()){
if (c.Total_years_as_a_rep__c != 0 && c.Total_years_as_a_rep__c != null && c.Estimated_T_12__c != 0 && c.Estimated_T_12__c != null &&
c.Estimated_T_12__c >= Quintile__c.T12_Min__c &&
c.Estimated_T_12__c < Quintile__c.T12_Max__c &&
c.Total_years_as_a_rep__c >= Quintile__c.LOS_Min__c &&
c.Total_years_as_a_rep__c < Quintile__c.LOS_Max__c
){
c.Estimated_Quintile__c = Quintile__c.Quintile__c;
}
}else
{
//handler code for no matching account
}
you are trying to compare and assign fields of Quintile__c sObject instead of an instance
Your code
instead of something like
Regards
if contact.Total_years_as_a_rep__c != '' and
contact.Estimated_T_12__c != ''
then
contact.Estimated_Quintile__c =
Select Quintile__C from Quintile__c
where
Quintile__c.start_date__c <= today() and
Quintile__c.end_date__c > today() and
contact.Estimated_T_12__c >= Quintile__c.T12_Min__c and
contact.Estimated_T_12__c < Quintile__c.T12_Max__c and
contact.Total_years_as_a_rep__c >= Quintile__c.LOS_Min__c and
contact.Total_years_as_a_rep__c < Quintile__c.LOS_Max__c
-
Quintile__c is, apart from the API name of the Object, the API Name of a field
-
contact is a variable, and you are not trying to make reference to the schema Object
Note that in order to use variables inside the query, you must put ":" before it.if you are trying to point to the Quintile itself, then you should retrieve the ID of the record and put it in the Lookup (or Master-Detail) field.
You would just have to replace "SELECT Quintile__c" with "SELECT ID" and "quintilesList.get(0).Quintile__c" with "quintilesList.get(0).ID"
Hope it helps ;)
When I comment out the code all tests run without error.