Is it possible to render calendar source background color according to a condition?

  • 1
  • Question
  • Updated 1 year ago
  • Answered
If a certain field in the event source is blank render a different color. i.e. In event display and background color settings in calendar source properties:
if {{AccountId}} isBlankValue then #FFFF00 else #00000

?
Thanks.
Photo of Gregg Baxter

Gregg Baxter, Official Rep

  • 3,080 Points 3k badge 2x thumb
  • exited using the various Calendar functions to bring my home page alive with color!

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
I think you can do this with Mustache merge syntax, yes, but the easiest way to do this would be to define a Formula Field, and then have your Background Color be determined by the Formula Field, e.g.

Background Color: {{CalendarColor__c}}

Where CalendarColor__c is a Formula Field you define in Salesforce, whose output is a Color, e.g. 

IF(ISBLANK(AccountId),"#FFFF00","#000000")


Photo of Poc

Poc

  • 496 Points 250 badge 2x thumb
Would you please show us how to show it within merge syntax without bothering formular field? Thanks
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Sure, you can do it with merge syntax but I would highly recommend adding a Ui-Only Formula Field on the Model (NOT a Salesforce Formula Field) rather than using merge syntax, as it's much cleaner and more understandable.

Ui-Only Formula Field approach:

Background Color: {{CalendarColor__ui}}

Where CalendarColor__ui is a Ui-Only Formula Field in the Model whose value is IF(ISBLANK(AccountId),"#FFFF00","#000000")

Merge Syntax approach:

Background Color: {{#AccountId}}#FFFF00{{/AccountId}}{{^AccountId}}lightgreen{{/AccountId}}

Translation: If we have an AccountId, color is #FFFF00, otherwise #000000

Either of these hard-coded values (e.g. #FFFF00 or lightgreen) can be substituted for a dynamic field value, e.g. {{CalendarColor__c}}
Photo of Gregg Baxter

Gregg Baxter, Official Rep

  • 3,080 Points 3k badge 2x thumb
Thanks Zach.. This opens up so many possibilities. I feel like Picasso on a blank page LOL