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
Lara MarshLara Marsh 

Can I use a formula in the filter of a roll-up field?

I have a situation where I have many Contacts and many Campaigns (which are actually Trips for our organization). Each Contact may be associated to any number of Campaigns. I need to track payments for each Contact, but I only want to do it for this year's trip (i.e. the current trip). 

I have a custom Payments object. It holds all payment records and tracks which Campaign and which Contact the payment is for. On the Contact, I have a roll-up field that sums the Payment records for that Contact only for records where the Campaign = the current Campaign ID. Right now, that Campaign ID value is hardcoded to the ID of our current trip. Can I reference a Custom Setting value or something in that filter so that I don't have to update the actual roll-up field each year and can instead update the constant?

Thanks.
Balaji Chowdary GarapatiBalaji Chowdary Garapati
The easy way is to create custom label and refer that in your formula., Follow the steps:
1)  create a custom label (setup>create>customlabel -> in value give your desired value)
2) you can refer in formula by using the $Label.[yourlabelname] (replace '[yourlabelname] ' with the name you had given) and you are done!

you can just change the value of label when ever needed, which will cause the recalculation of rollup fields which might take upto 30 minutes as per salesforce documentation.


Hope this helps:

Thanks,
Balaji

 
Lara MarshLara Marsh
Thanks, Balaji -

I'm a bit confused still. :) 

So I created a Custom Label as follows:

Name: CurrentXicoTrip
Type: List
Short Description:  CurrentXicoTrip
Value: 701q0000000B2AI (this is the Campaign ID of the current trip)

Then I went to my roll-up field on the Contact. The formula looks like this now:
(Campaign ID EQUALS $Label.[CurrentXicoTrip])

But it is not rolling up. It shows $0 for the sum when it should be the sum of two records ($200 and $800 = $1000).

Am I not referencing it correctly? Sorry, I'm sure this is basic. Thanks for your help.
Lara
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Hi Lara,

 You almost there!., sorry for creating confustion it is not

(Campaign ID EQUALS $Label.[CurrentXicoTrip])

it will be


(Campaign ID EQUALS $Label.CurrentXicoTrip)

:)
Lara MarshLara Marsh
Thanks, Balaji. I tried this and it's not working. I have a support person working on it. Thanks for your help!