Checkbox Rendering Parameter Taking Null Value If It's Unchecked
Issue: I have a client requirement that each component should be flag-based to turn it on or off. I have used a checkbox in rendering parameters for the implementation of this functionality and applied that rendering parameter template on each component rendering.
While reading these values, If I checked the Checkbox IsComponentVisiable it returns "1" and unchecked the Checkbox, it returns me null.
var flag= RenderingContext.Current.Rendering.Parameters["IsComponentVisible"]
I was surprised about its behaviour that instead of "0" it returns null? I raised the support ticket to Sitecore to understand that am I doing something wrong or if it's the default behaviour of the checkbox field when we use it as the rendering parameter?
Sitecore suggested:
Find below the Sitecore Team Response on my Ticket:
Based on the provided information we would like to define the scope of the current case:
Issue definition: False value for bool rendering parameter is retrieved as null.
Investigation target: we will work diligently to help find the root cause and a resolution to the defined issue.
Additional notes: if new circumstances are revealed during the investigation, the scope can be changed based on the mutual agreement;
overall investigation course will be aligned with Sitecore general Scope Of Support: https://kb.sitecore.net/articles/463549;
questions that are not related to the investigation scope should be registered as separate cases: https://kb.sitecore.net/articles/004553.
Thank you for reporting the issue. I was able to reproduce it locally and registered a bug for the current Sitecore version. To track the future status of this bug report, please use reference number 502996.
More information about public reference numbers can be found here: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0853187
As a workaround, please consider the parameter value as true if it is present and equals 1.
Happy Sitecoreing 😊
Which Sitecore version is this? Seriously sitecore coding standards falling each day
ReplyDelete