You need to sign in to do that
Don't have an account?
Edgar Macachor
sum of a field using apex trigger
Hi help guys! I am really new in salesforce and also in Apex. I have to create an Apex Trigger to get the sum of a field. my components are:
Hi help guys! I am really new in salesforce and also in Apex. I have to create an Apex Trigger to get the sum of a field. my components are:
1. Price - custom object
The fields of Price are:
3. Sale - custom object
The fields of Sale are:
So the instruction is to get the sum for Discount Line and Discount Price. The formula is:
Discount Line = Sum of ACTIVE applied discounts for Column Stage Sale
Discount Price= Sum of ACTIVE applied discounts for Row Stage Sale
Both custom object has no relationship to each other. The event is before insert, before update. Please help me guys. Ask me for clarifications. Thank you.
Hi help guys! I am really new in salesforce and also in Apex. I have to create an Apex Trigger to get the sum of a field. my components are:
1. Price - custom object
The fields of Price are:
- Discount Line (currency field type)
- Discount Price (currency field type)
3. Sale - custom object
The fields of Sale are:
- Status (Picklist: Draft, For Approval, Active)
- Min Sale Amount (currency)
- Min Sale Quantity (number)
- Discount Sale (currency)
- Row Stage
- Column Stage
So the instruction is to get the sum for Discount Line and Discount Price. The formula is:
Discount Line = Sum of ACTIVE applied discounts for Column Stage Sale
Discount Price= Sum of ACTIVE applied discounts for Row Stage Sale
Both custom object has no relationship to each other. The event is before insert, before update. Please help me guys. Ask me for clarifications. Thank you.
Hi Edgar Macachor,
Please try this code for Insert Only because for an update there needs to be a relationship between Sale and Price.
Please let me know it is working or not??
If it works don't forget to mark Best Answer.
Thank You