Render Sections Based on Model Field Month Matching This Month

  • 1
  • Question
  • Updated 1 year ago
  • In Progress
I have overriden a Salesforce tab, and am trying to dynamically render sections or rows based on today's current date and a picklist field with month numbers (ie. 7 = July).

I have added an UI-Only Model, and have set a render condition looking to that model, but it doesn't appear to be working. Here is the UI-Only Model:


And here is the rendering condition:


(Work_Anniversary_Month__c is a picklist of month numbers 1-12)

So the end goal is to display sections or rows based on if the row has Work_Anniversary_Month__c = TODAY(Month)

Does anyone have some insight into how to get this to work?
Photo of Meg Cassell

Meg Cassell

  • 100 Points 100 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
You could try displaying the values from both fields in something like a rich text component on your page to see if you are getting the values you are expecting. You could also try to do the comparison inside of the UI only formula field and have it return true or false, then render components/fields based on the formula returning true or false.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I would move the UI only fields to the same model that the components use. I've had issues working with conditional rendering based on values from another model.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Oh ... and the value you have needs double mustache. {{}}
Photo of Meg Cassell

Meg Cassell

  • 100 Points 100 badge 2x thumb
Thanks for the suggestions! I tried moving the UI only fields to the component model and changed the mustaches, and unfortunately still not working. Here is the formula for the UI only field:


And here is the updated rendering condition:


Any thoughts on why this still isn't working?
Thanks!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Did you try adding the UI only fields to a field editor to see the values live?
Photo of Meg Cassell

Meg Cassell

  • 100 Points 100 badge 2x thumb
I did - the formula is pulling up the correct number, but it likely has something to do with returning multiples. See screenshot:


The goal is to list rows in a section if the Work Anniversary Month = CurrentMonth. But as you can see, when the UI only field is in a field editor on the page it returns multiple rows.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
What is the birthday month value?
Photo of Meg Cassell

Meg Cassell

  • 100 Points 100 badge 2x thumb
Birthday Month and Anniversary Month are both picklists with values 1-12. So when updating a row with Birthday Month or Anniversary Month with "7", right now it would say "7" on the row but that still doesn't meet the render condition for some reason.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Can you post the XML for the page?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I am fairly confident that if you do the formulas as salesforce fields instead of Ui only, then add then to your models, then base the render conditions on those fields you will get the result you are looking for.