You need to sign in to do that
Don't have an account?
Vishwanath
Problem with displaying error message in trigger
Hi,
Please help me from this issue,
i need to display the error message on field when the list is empty
Trigger code
trigger InvoiceAmountCal on UOP_Royalty_Payment_History__c (Before insert,Before Update) { Double ReportOverage; Double diffOverage; Double AuditOverage; for(UOP_Royalty_Payment_History__c UOP:Trigger.new) { if(UOP.Payment_History_Event__c!='Report') { UOP_Royalty_Payment_History__c UOPList=[select id,name,Payment_History_Event__c,Overage__c,Throughput__c,Previous_Fully_Paid_Capacity__c from UOP_Royalty_Payment_History__c where Payment_History_Event__c=:'Report' and Process_Unit__c=:UOP.Process_Unit__c and UOP_Year__c=:UOP.UOP_Year__c]; ReportOverage=UOPList.Overage__c; if(ReportOverage==null) { Trigger.new[0].UOP_Year__c.addError('There is no Report in '+UOP.UOP_Year__c+''); } else { AuditOverage=UOP.Throughput__c - UOP.Previous_Fully_Paid_Capacity__c; diffOverage=AuditOverage - ReportOverage; if(diffOverage <= 0) { UOP.Invoice_Ammount_For_FA_DA__c=0.0; } else { UOP.Invoice_Ammount_For_FA_DA__c=diffOverage * UOP.Royalty_Rate__c * (UOP.Applicable_BLS__c / UOP.BLS_Base__c); } } } } }
in above trigger if ReportOverage==null or the UOPList==null then it should display error
but when im save the record trigger displaing error list has no rows for assissgment to Sobject
Hi,
you can try below code
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
you can try below code
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi jain,
Thanks a lot its working fine,
one more isuue, im writting the trigger as explained below but it hits too many scrits 2000001 statment can u
give some code solution that help me to avoid this error
i have three object A <--- B <--- C
A is parent to B, and B is Parent to C
assume in A1 records have near about 100 of child record (Ex ; b1,b2,b3,b4,b5.....................)
when i insert c1 child in b1 parent, it should be insert in all b2,b3,b4,b5..................... (Ex ; b1 <-- c1, b2<--c2, b3<--c3 ,........)
and if i update any one it should be update in all
Thank u
That's a very odd request. You're going to really have difficulty with data space in that configuration.
Maybe expand on why one record needs to be duplicated for each parent's sibling?
What are these actual objects?
p.s. Should have created another message post for a different question.