You need to sign in to do that
Don't have an account?
etechcareers
Going to a LIST???
HI:
I have a table with bonus amounts in it depending on Comp_Plan
If the Level of the Person is 100 let's say and in the CompPlan table a level of 100 is $2000, and another level of a person is 60 and bonus is $1000...
My code is picking up the $1000 instead of $2000 when the level of that person is 120...
trigger bonusAmount on Compensation__c (before insert,before update) { List<Compensation__c> pu = new List<Compensation__c>(); for(Compensation__c o: Trigger.New){ List<Comp_Plan__c> accountWithOpptys = [Select id, Comp__c,Goal__c,Category__c,Goal_Amount__c,Level__c from Comp_Plan__c where Team_Goal__c=True AND Comp__c =:o.Comp_plan__c]; System.Debug('***'+accountWithOpptys.size() + o.Comp_Plan__c); //This is correct brings up 8 records for Comp_Plan__c=AA and the levels from 30-100 with the Goal_Amount... if(o.NELevel__c >= 100){ //In the record I am editing the level is 120 which is greater then 100 but the person should get 2500 yet it is getting 1000 which the 1000 is for level 60???? o.NEBonus__c = accountWithOpptys[0].Goal_Amount__c; pu.add(o); } } }
Hope this helps please...
thanks
Z
Try this.
All Answers
Try this. Let me know if it doesnt work.
-Naidu
Hi Thank you so much... But i get an error stating Compile Error: Incompatible key type Decimal for MAP<Integer,Double> at line 23 column 17
Level__c ==>Number(18,0)
Goal_Amount__c==>Currency(18,0)
So dont understand why am I getting the number it seems to be mapped correctly...
Thanks
Z
Try this.
Thank you that did solve the issue but the when i edit the record or new record I get this:
Apex trigger bonusAmount caused an unexpected exception, contact your administrator: bonusAmount: execution of BeforeUpdate caused by: System.StringException: Invalid id: AA: External entry point
The Comp_Plan__c is a string...not an id...So I changed it to the following: and it worked...
Thank you for everything
Z