Monday, November 23, 2015

How to have a star rating field on custom object in salesforce


Well, in that case, you'll have to create a separate field, most probably a Picklist Field would suit the need. You can create a Picklist Field say -
Label: RatingCode
Type: Picklist
Values:
1
2
3
4
5
And then create a another Formula Field on the same object. This is to represent the Rating "pictorially". That field would look like this -
Formula Return Type: Text
Label: StarRating
Type: Formula
Formula: 
IF(
    ISBLANK(TEXT(RatingCode__c)),
    NULL,
    IMAGE(
        "/img/samples/stars_" + TEXT(RatingCode__c) + "00.gif",
        "Rating Level"
    )
)

Output:-

5 comments:

  1. the formula is not understanding. that is image type the url is default or we need to save the star.gif image in static resources pls help me it is not working with me ?

    ReplyDelete
  2. Hi, Salesforcepunk/
    the code was executed but i didn't know that, is there star field like 00.gif image was already exists in sandbox ? pls clarify me

    ReplyDelete
    Replies
    1. Hi Moghal,
      By default 00.gif is available in Orgs. No need to upload in static resource .

      Delete
  3. Above scenario can u explain briefly I did't understand

    ReplyDelete
  4. Above scenario can u explain briefly I did't understand

    ReplyDelete