Here is an example of Star Rating field using Formula in Salesforce. In below example I’m displaying the Star Rating, based on a Student’s grade.
In Student custom object, I have created a Picklist Field.
And then I have created a Formula Field on the same Student object. This is to represent the Star Rating.
IF(TEXT(Grade__c) = '0', "/img/samples/stars_000.gif",
IF(TEXT(Grade__c) = '1', "/img/samples/stars_100.gif",
IF(TEXT(Grade__c) = '2', "/img/samples/stars_200.gif",
IF(TEXT(Grade__c) = '3', "/img/samples/stars_300.gif",
IF(TEXT(Grade__c) = '4', "/img/samples/stars_400.gif",
IF(TEXT(Grade__c) = '5', "/img/samples/stars_500.gif",
Here is an example of Progress Bar field using Formula in Salesforce. In below example I’m displaying the percentage progress bar, based on a Student’s scored out of total marks.
Percentage Formula Field:
IMAGE("/img/samples/color_red.gif","red",10, 100 - ((Scored__c/Total_Marks__c)*100)) &
" " & TEXT((Scored__c/Total_Marks__c)*100) & "%"
In Salesforce formula field using
IMAGE(image_url, alternate_text, height, width) function, we can insert an image with alternate text and height/width specifications.
In below example, I’ve created a custom field “
Priority__c” in “Case” object with below formula. This formula displays a red, yellow, or green flag image to indicate case priority High, Medium or Low.
IF(TEXT(Priority) = 'High', IMAGE("/img/samples/color_red.gif", "Red", 10 , 50),
IF(TEXT(Priority) = 'Medium', IMAGE("/img/samples/color_yellow.gif", "Yellow", 10, 50),
IF(TEXT(Priority) = 'Low', IMAGE("/img/samples/color_green.gif", "Green", 10, 50),
Follow the below steps to create a formula field that will give you the 18 characters ID of the records.
- Go to Setup | Customize | object name | click Fields
(For Custom objects: Setup | Create | Objects | Object Name)
- In the related list “Custom Fields & Relationships” click New.
- Click the Formula radio button.
- Click the Text radio button for “Formula Return Type”.
- 6. Input the following Formula into the Formula Editor:
- Set Field Visibility, add/ remove from Page Layout(s).
- Click Save.
NOTE: When dealing with record types only custom record types have ids.
To display Salesforce as a User License type on report, Below is the workaround:
- Create a Custom Formula Text field under the User object:
- Go to Setup | Customize | Users | Fields
- Click on New and select “Formula” field type and then “Text”
- Use “Profile.UserLicense.Name” in the formula editor
- Click on Save
- Create a New Administrative User report:
- Go to the Report tab
- Click on New report
- Under the Administrative reports | Select Users
- Add the New Custom Formula field in the report
- Run the Report and Save