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, 2022 in SalesForce by surbhi
• 3,820 points
1,081 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.

Hope this helps!

Check out this Salesforce admin course to learn more.

answered Mar 17, 2022 by CoolCoder
• 4,420 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, 2022 in SalesForce by surbhi
• 3,820 points
770 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, 2022 in SalesForce by CoolCoder
• 4,420 points

edited Jun 19, 2023 by Khan Sarfaraz 1,487 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, 2022 in SalesForce by CoolCoder
• 4,420 points
6,967 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
3,342 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,030 points
1,018 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,030 points
710 views
0 votes
2 answers

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

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

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

edited Dec 22, 2021 by Soumya 707 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, 2022 in SalesForce by CoolCoder
• 4,420 points
3,316 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP