function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Angieme1Angieme1 

Cross object Workflow

HI,
I don't know Apex (I'm starting to learn)

I have a custom object called Product menu (I had to customize this because we sell services and our pricing is so unique I couldn't use products or price books).

Each Product instance is tied to an Opportunity, so an opportunity could have 1 to many Products.

Within each Product I have Hourly fee, Sourcing fee and Base fee by year, so I have 2008 Hourly fee, 2009 Hourly fee, 2010 Hourly fee, 2008 base fee etc....

Since an opportunity can have more than  1 product, I created a field in Opportunity called 2008 Total deal value, 2009 Total Deal Value etc

I want the 2008 Total deal value in Opportunity to add up all the 2008 Total deal values from the products. So, if an opportunity has 4 products, it would add the 2008 Total deal value from each of the products.

Each Product is linked to an opportunity, so I should be able to do this. I tried to create a workflow on the Opportunity object, but it only let me create a workflow based on fields within Opportunites. I tried to do a formula field, but it only allowed me to do this for Opportunity fields. I want to add up the results from Products and put it into the Opportunity field

Can Apex handle this? If so, is there simple code I could use?
David VPDavid VP


Not sure if this will work but couldn't you create a formula field on your Products that will calculate the TotalDealValue2008 / TotalDealValue2009 / ... and than do a formula roll-up summary of these in Opportunity ?

Wouldn't it be better if the year was just another field that you could set a value on in your custom products. Like that you could use the standard roll up summaries by just counting the records where year == 2008 etc ... ?



David
Angieme1Angieme1
Thanks David,

I would love it if I could have year as a field, but the way we are structured here, it wouldn't work. I've tried multiple things and even worked with Salesforce on this, and it just isn't possilbe.

I tried to do exactly what you were talking about. I created a field in Opportunity and tried to do a formula that added up all the 2008 deal values from products, but Salesforce doesn't allow me to choose any product fields in the opportunity formula.(product being my custom object, not the salesforce products) I

In Products I can choose Opportunity fields, but in Opportunity fields, I can't choose product fields, therefore I can't figure out how to do a roll-up.

Angie
Marc PannenbergMarc Pannenberg
Hi Angie,

I think you may have misunderstood David. He suggested using a roll-up formula to sum up related records. You are correct, formulas only give access "upwards", i.e. to fields of records the current record is related to.

In order for roll-up formulas to be available, your custom object needs to be in a master-detail relationship with the parent object (i.e opportunity in your case).

When setting up your roll-up summary field you are given the option of only summing up records that match a certain criteria and a block of filters. If you have one field on your product records that specifies the year, then you would use that as the criteria.

I hope this helps and I wasn't repeating the obvious :)

Marc
Senior Business Analyst
Saaspoint Ltd.
Angieme1Angieme1
OH!
I've seen the master roll-up , but didn't really understand it. I will give this a try-

Thanks!
Angieme1Angieme1
YAY!!! That worked!!!!!
I'm so excited.

Thank you.
David VPDavid VP
Glad it worked for you :smileyhappy: