Skip to content

Fix: File/Image attributes missing from filtering attributes selector - #168

Open
dbarros97 wants to merge 1 commit into
imranakram:masterfrom
dbarros97:fix/filtering-attributes-missing-file-type
Open

dbarros97 wants to merge 1 commit into
imranakram:masterfrom
dbarros97:fix/filtering-attributes-missing-file-type

Conversation

@dbarros97

Copy link
Copy Markdown

Summary

File and Image attributes never appear in the "Filtering Attributes" picker (opened from Step Registration), for Update or any other message that supports filtered attributes. They are silently excluded before the selection dialog even renders.

Root cause

AttributeSelectionForm's constructor builds its selectable attribute list from an explicit allow-list keyed on AttributeTypeCode:

case AttributeTypeCode.CalendarRules:
case AttributeTypeCode.Uniqueidentifier:
case AttributeTypeCode.Virtual:
    if (attribute.IsPrimaryId || attribute.TypeName == "MultiSelectPicklistType")
    {
        addattribute = true;
    }
    break;

Dataverse doesn't give File or Image (new-style) columns their own AttributeTypeCode. Both report AttributeType = Virtual (the same code multi-select picklists use), and the concrete subtype is only distinguishable via AttributeTypeName.Value ("FileType" for File columns, "ImageType" for Image columns) - the exact mechanism already used here to special-case "MultiSelectPicklistType".

Because the Virtual case only checked IsPrimaryId and "MultiSelectPicklistType", every File and Image attribute fell through with addattribute == false and was dropped from m_attributesList before the form loaded.

CrmAttribute (Wrappers/CrmAttribute.cs) is unaffected - it passes through whatever AttributeType/AttributeTypeName the metadata service returns. The bug is isolated to the allow-list in AttributeSelectionForm.

Fix

  • Add "FileType" and "ImageType" to the existing TypeName check in the Virtual case, alongside "MultiSelectPicklistType", so File and Image attributes are included in the selectable list.
    • Extract the inline type-name-to-display-string ternary into a GetDisplayTypeName helper and extend it to show "File" / "Image" in the Type column, instead of the generic "Virtual" AttributeTypeCode - consistent with how "MultiSelect Picklist" is already shown instead of "Virtual".
      No other files needed changes; the CrmAttribute[] flowing into this form already carries the correct AttributeTypeName.

Testing

This is a .NET Framework 4.8 WinForms project, so it wasn't feasible to build/run it in the environment used to prepare this change. The change was reviewed by hand: it only extends an existing allow-list with two additional AttributeTypeName values and extracts a passthrough display-name helper, with no changes to behavior for any previously-supported attribute type.

Manual verification recommended before merge: register/edit a step for the Update message on an entity with a File or Image attribute (e.g. a custom File column) and confirm it now appears, checkable, in the Filtering Attributes dialog, with "File"/"Image" shown in the Type column.

Risk

Low. Only widens the existing allow-list for two additional AttributeTypeName values and adds a passthrough helper for display text; no behavior changes for attribute types that were already supported.

File and Image attributes report AttributeTypeCode.Virtual, distinguished only via AttributeTypeName ("FileType"/"ImageType"), the same way MultiSelectPicklistType is distinguished. The Virtual case in AttributeSelectionForm's constructor only special-cased MultiSelectPicklistType, so File and Image attributes fell through with addattribute == false and were silently dropped from the filtering attributes list before the dialog rendered. This adds FileType/ImageType checks alongside MultiSelectPicklistType, and extracts a GetDisplayTypeName helper so the Type column shows "File"/"Image" instead of the generic "Virtual" AttributeTypeCode.
@sj-cardoso

Copy link
Copy Markdown

Really excited to see this one! Missing File and Image columns in the Filtering Attributes picker has been a pain point for a long time, and it's great to finally see a fix. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants