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

Cross Object Formula Field

Hi All - thanks in advance for the help.

I have a set of custom fields on a custom object - called "Benefits" - to track codes which people use to register for a conference. "Benefits" custom object lives on the campaign. 

I want to create a formula field on the "Benefits" object called "Codes Used" which counts the number of campaign members who have the <<Member Status>> = "Registered" and <<Discount Code>> = <<code on the benefit object>>.

Possible? Easy to set-up? What kind of code would be required? 

Thanks so much!
Rajneesh Ranjan 23Rajneesh Ranjan 23
I think you can write a trigger to get the count, but before that I have few questions here:
  1. Is Discount Code a pick list field and present on either object, or it is fixed for the campaign record and a user select this Code on Benefit object only?
  2. How these two objects are related? Is it MD or Lookup? Which object is child and which is parent in this relationship?
R Z KhanR Z Khan
Hi Squirrel,

Does Benefits object have a Lookup onto Campaign? If so, you cannot do this. You could create a number field adn then wirte a trigger on Benefit obejct to query the related Campaigns and update the field. You would also need ot write a trigger on campaign object in case "Discount Code" gets updated or Memebr status field.