1

I've added a custom EntityView via IGetEntityViewPipeline, but none of the text is appearing. I can see that it's been rendered, but all of the text values are blank (even in the rendered markup).

My code looks something like this:

entityView.ChildViews.Add(new EntityView()
{
    EntityId = entityViewArgument.Entity?.Id ?? string.Empty,
    Name = myCustomViewsPolicy.ViewName,
    UiHint = "Flat",
    ItemId = entityView.ItemId,
    Properties = new List<ViewProperty>
    {
        new ViewProperty
        {
            Name = nameof(CustomComponent.Property1),
            RawValue = customComponent.Property1,
            IsReadOnly = true
        },
        new ViewProperty
        {
            Name = nameof(CustomComponent.Property2),
            RawValue = customComponent.Property2,
            IsReadOnly = true
        }
    }
});

1 Answer 1

1

The problem here comes down to pipeline block placement.

The properties that are used to display the labels in BizFX are actually EntityView.DisplayName, ViewProperty.DisplayName, and ViewProperty.Value. IGetEntityViewPipeline is configured to end by invoking the IFormatEntityViewPipeline pipeline, which attempts to resolve reasonable values for the display properties (which can be overridden by defining "Business Terms" in Sitecore).

If you don't specify a position when you register your custom block it will be placed at the end of the pipeline, after IFormatEntityViewPipeline has already run. And since that means your custom view doesn't have any values in the display properties, they appear blank in the UI.

The solution is to either register your block after a known block or before IFormatEntityViewPipeline (depending on what semantics are most relevant to understanding your intent):

services.Sitecore().Pipelines(p => p
    .ConfigurePipeline<IGetEntityViewPipeline>(c => c

    // Either of these two will do the job:

        .Add<CustomViewBlock>()
            .After<GetSellableItemDetailsViewBlock>()

        .Add<CustomViewBlock>()
            .Before<IFormatEntityViewPipeline>()
    )
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.