Console icon indicating copy to clipboard operation
Console copied to clipboard

Get-Item behaves weirdly when dealing with Checkbox fields having "false" (empty)

Open hugosantos-konabos opened this issue 2 years ago • 1 comments

Expected Behavior

Get-Item should handle FALSE checkbox values as FALSE instead of inheriting its value from the standard values item.

Actual Behavior

Get-Item handles FALSE checkbox values as EMPTY, thus inheriting its value from the standard values item.

Steps to Reproduce the Problem

Create one template that has a checkbox field. Set its default value to TRUE.

Now create an item using this template. You will see that Sitecore uses its default value, so the value is TRUE.

Manually unselect this checkbox. It's now FALSE. But if you open the "raw values", you will see that Sitecore stores an "empty" value that means FALSE. Behind the scenes, Sitecore is smart enough to know that this EMPTY is actually FALSE and do not inherit its default value from standard template item.

SPE is doing the opposite. When facing an empty boolean field value, SPE is getting the standard value template. Here is a short SPE script and its results to show this: image

Both checkboxes "Use Global Header" and "Use Global Footer" have "TRUE" as standard value. But as you can see, the source item already had those two fields set to "FALSE". After copying them to the target database, those fields are now back to "TRUE" again.

hugosantos-konabos avatar Apr 13 '23 15:04 hugosantos-konabos

@hugosantos-konabos Can you demonstrate that this issue still occurs without the use of SPE? I suspect this is the behavior of the platform and not something introduced by SPE.

michaellwest avatar Aug 02 '23 22:08 michaellwest

@hugosantos-konabos - I did some testing and cannot replicate the results that you are getting not matter what. The value returned is false or empty string is as expected. image

I've noticed that you are copying items between the databases which would suggest to be that this could have been caused by the Sitecore "transfer" functionality but even when I attempted to do this between the databases - I am getting the correct results(as depicted in the image above where I'm copying the item to the core database).

I am at a loss. Maybe it has something to do with the face that one of the databases is coming form an old version of Sitecore? Or maybe this field is versioned and not all versions are transferred and the version that gets copied has a different value?

Since this is over a year old and not replicable, I'm closing it as stale. Please reopen if there is any new information that could help us replicate the result.

AdamNaj avatar May 11 '24 19:05 AdamNaj