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
ericszulcericszulc 

Constant as part of object definition (or best possible way to solve this)?

Hello all,

 

I have the scenario where I'd like to have a constant value across all records in an object while being able to update that value frequently.

 

For instance, Let's say I have 3 records in Object A with a field called "value".

 

Record 1) Value:0;

Record 2) Value:5;

Record 3) Value:50;

 

Now, let's say I want a constant that scales all values in, say, a formula field, such that the values are from 0-100. So, constant = 2.0

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:10;

Record 3) Scaled Value:100;

 

Now, imagine i added a fourth record

 

Record 4) Value:100;

 

And now the constant = 1.0;

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:5;

Record 3) Scaled Value:50;

Record 3) Scaled Value:100;

 

What's the smoothest way to accomplish this? I thought I might be able to change a formula definition within an Apex trigger. Thinking that's not likely. Is there a way to define a field with a constant value. Again, I'd have to be able to change via an Apex trigger or scheduled code.

 

The only solution I have so far, is to just have lookup fields to another object (object b) that contains all the constants. Change the values in this second object's records and repeatedly check every record of object A  to ensure that it's always pointing to the right record in Object b. Of course, this seems to be quite awkward.

 

Are there any other possibilities that I'm missing?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
geetageeta

you can use custom settings.

All Answers

geetageeta

you can use custom settings.

This was selected as the best answer
ericszulcericszulc

So simple! How did I miss this? Thanks geeta!