Salesforce How to update a roll-up summary field on parent table from inside method that gets triggered when child is persisted

0 votes
I made a Commission object with a commission amount c property that has a master detail relationship with Contact. Total Commission c is a sum up field on Contacts that adds up all commission amounts from Commissions associated to each Contact. I've added a trigger to Commission that calls the updatePrimary function. When I query this inside updatePrimary, I receive the old value in the sumup field(total commission), not the new value with the new commission amount appended. It hasn't come to a conclusion yet. If at all possible, some assistance would be greatly appreciated.
Mar 15 in SalesForce by surbhi
• 3,810 points
54 views

1 answer to this question.

0 votes
At the save order of execution, you're in the wrong place.

After the triggers are fired in Step 8, the parent object's roll-up summary fields are changed in Step 18.

You'll need to put a trigger on the parent object if you want to react to the update of your roll-up summary field. If I understand your requirement properly, you might be able to create a formula field on the Commission object that references the Contact's roll-up summary field.
answered Mar 17 by CoolCoder
• 4,360 points

Related Questions In SalesForce

0 votes
0 answers

Salesforce API: How to identify a Case from an email reference code ("[Ref: ... :Ref]")?

1 I'm writing a Windows service that will ...READ MORE

Apr 5 in SalesForce by surbhi
• 3,810 points
41 views
0 votes
1 answer

How to log into a salesforce.com sandbox?

My user account was created after the ...READ MORE

answered Mar 15 in SalesForce by CoolCoder
• 4,360 points
27 views
0 votes
1 answer

How do i get all values from a global pick list in salesforce using REST Api?

Since API 39.0 it is possible to ...READ MORE

answered Mar 17 in SalesForce by CoolCoder
• 4,360 points
311 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
1,835 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,010 points
289 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,010 points
174 views
0 votes
1 answer

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Training that covers all ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 204 views
0 votes
1 answer

How to Update RecordTypeId field in Lightning record form in salesforce?

A critical action that messes everything up ...READ MORE

answered Mar 3 in SalesForce by CoolCoder
• 4,360 points
224 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP