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

Convert object to double use newvalue in history
Illegal assignment from Object to Double
for (OpportunityLineItem oli : [SELECT Margin_Percentage__c, Margin_Amount__c, PriceBookEntry.Id, PricebookEntry.Product2Id,PricebookEntry.product2.id,
PricebookEntry.product2.Service_Line__c FROM OpportunityLineItem WHERE Opportunityid in :oppnew]) {
Product_Service_Lines__history PSL= [Select NewValue From Product_service_lines__history
WHERE Field='Margin_percent__c'
AND Createddate < :CD
AND ParentId=:oli.PricebookEntry.product2.Service_Line__c
ORDER BY Createddate desc
LIMIT 1];
oli.Margin_Percentage__c=PSL.NewValue;
I get the following error message : Illegal assignment from Object to Double
How I can use this newvalue field to track old value
for (OpportunityLineItem oli : [SELECT Margin_Percentage__c, Margin_Amount__c, PriceBookEntry.Id, PricebookEntry.Product2Id,PricebookEntry.product2.id,
PricebookEntry.product2.Service_Line__c FROM OpportunityLineItem WHERE Opportunityid in :oppnew]) {
Product_Service_Lines__history PSL= [Select NewValue From Product_service_lines__history
WHERE Field='Margin_percent__c'
AND Createddate < :CD
AND ParentId=:oli.PricebookEntry.product2.Service_Line__c
ORDER BY Createddate desc
LIMIT 1];
oli.Margin_Percentage__c=PSL.NewValue;
I get the following error message : Illegal assignment from Object to Double
How I can use this newvalue field to track old value
I didn't have your custom object, but was able to cast this anyType to double using double.valueof()