+ Start a Discussion
pgonzaleznetworkpgonzaleznetwork 

How to use custom setting in formula field

Hi Team,

 

I'm trying to understand how custom settings work.

 

I created a hierarchical custom setting called Tax and it's got two fields in it.

 

Role(text)

Percent(percent)

 

I created two data sets, one where the assigned profile is System Administrator and another one where the assigned profile is Standard User.

 

The data sets are as follows:

 

Name:Admin

Location: System Administrator

Role:System Administrator

Percent: 10

 

Name:stdUser

Location: Standard User

Role: Standard User

Percent: 32

 

Then, I created a formula text field with the following syntax

 

"Your role is $Setup.Taxes__c.Role__c"

 What I wanted to happen,is that if I'm logged in as an Admin, I should see "Your role is System Administrator" but if I'm logged in as a standard user I should then see "Your role is Standard User" but regardless of the user I'm logged in as, the formula displays Your role is $Setup.Taxes__c.Role__c

 

Any advise?

 

Thanks

 

Pablo Gonzalez

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Shannon HaleShannon Hale

Pablo, I think the only thing wrong with your formula is that you put the custom setting merge field syntax inside the string quotes, so it's being output as a literal rather than the value.

 

Try this:

 

"Your role is " & $Setup.Taxes__c.Role__c

 

All Answers

Tejpal KumawatTejpal Kumawat

Hi Pablo Gonzalez

 

Try to use this Formula in your Formula field.

 IF( $Setup.Taxes__c.Role__c = 'System Administrator', 'System Administrator',  IF( $Setup.Taxes__c.Role__c = 'Standard User', 'Standard User', '') ) 

 

If any issue please let me know

pgonzaleznetworkpgonzaleznetwork

Hi Tejpal,

 

That seemed to work! but do you know why I'm unable to simply display the value of $Setup.Taxes__c.Role__c instead of comparing string values against it like in your formula?

 

Thanks

Tejpal KumawatTejpal Kumawat

Hi Pablo Gonzalez

 

Beacause of in your formula thare are you have two data sets for one custom setting, And it gives any one result at the real time running of formula field.

Shannon HaleShannon Hale

Pablo, I think the only thing wrong with your formula is that you put the custom setting merge field syntax inside the string quotes, so it's being output as a literal rather than the value.

 

Try this:

 

"Your role is " & $Setup.Taxes__c.Role__c

 

This was selected as the best answer
pgonzaleznetworkpgonzaleznetwork

You know Shannon, I feel embarrased :p

 

This was so simply/basic, but I'm sure it will never happen again.

 

Thanks! 

Shannon HaleShannon Hale

Oh, I'm sure it will. I do it all the time :-)