You need to sign in to do that
Don't have an account?
cristian.dev
Trigger development: Illegal assignment from Schema.SObjectField to Double
Hi all.
I'm writing my first trigger on SalesForce.
The goal would be: determine the value of a proposal (Proposal__c) updating its field called Proposal_Value__c (Currency), getting the sum of Item_Value__c(currency) that resides in a Proposal child object.
The trigger should be called inserting, updating or deleting a proposal Line_Item
trigger updateProposal on Proposal_Line__c (after delete, after insert, after update) {
Double proposalValue = Proposal__c.Proposal_Value__c;
List proposalLines =
[SELECT j.Proposal_Line_Value__c FROM Proposal_Child__c j FOR UPDATE];
for (Proposal_Child__c pl: proposalLines) {
proposalValue += pl.Proposal_Line_Value__c;
}
update proposalValue ;
}
I have an error declaring proposalValue (the first variable): Illegal assignment from Schema.SObjectField to Double
I've also checked in the schema explorer that says this variable is of Double type.
Thanks for any suggestion.
In this line:
Proposal__c is an object type definition, so Proposal__c.Proposal_Value__c is simply a field definition.
You'll need to retrieve an instance of Proposal__c and use that to set your initial value.
hi
Error in line 2.
you can't get the proposal_value__c property until there is no proposal__c instance initalized!