1

I am trying to create a Component Template which functions in Retrofit mode. When I add the Publish Mappings building block to the Component Template, attempting a render gives me the following message:

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Sdl.Web.Common.Models.Data.SummaryData]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Sure enough, the Output generated by the Render Component Content is a JSON object (thus, not an array) that looks like this:

{
    "Component":{<<Content here>>},
    "ComponentTemplate":{<<CT details here>>},
    "IsDynamic":true,
    "OrderOnPage":0
}

I've tried putting Publish Mappings at various locations in the pipeline, but it doesn't help.

What am I doing wrong?

4

I'm not sure why you are trying to add the Publish Mappings TBB to your Component Template. The documentation mentions:

... By invoking the Publish Mappings Template Building Block from the Publish Setting Template Building Block with its retrofitMode parameter set to true.

So all you need to do is leave your Component Template alone, and configure the retrofit mode, see also the changes introduced in DXA 1.7:

To accommodate the existing Content Model, in the Publish Settings Template Building Block, found in the Folder 100 Master/Building Blocks/Framework/Developer/Templates/, set the retrofitMode parameters of each of the Publish Mappings Template Building Blocks to true. This ensures that Schemas and Schema fields are mapped to unique identifiers on the DXA side.

I don't have a 1.7 system at hand, but I think the plural in the documentation is a typo, since I'm guessing there is only one Publish Mappings TBB in your Publish Settings TBB. As for changing the mentioned parameter, you can easily do it via the Template Builder, or use the following XML in the source tab (tcm:1-2-2048 is a dummy TCM URI, use your own ;o):

<Template xlink:href="tcm:1-2-2048" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Publish Mappings" />
<TemplateParameters>
  <Parameters xmlns="http://www.sdl.com/web/schemas/publishmappings">
    <retrofitMode xmlns="http://www.sdl.com/web/schemas/publishmappings">true</retrofitMode>
  </Parameters>
</TemplateParameters>
| improve this answer | |
  • Thanks Bart. It's clear now. My problem was not the typo, but the fact that Publish Settings is described as a TBB. Once you know that you have to find a Component Template belonging to the framework, it's clear enough. – Dominic Cronin Oct 18 '17 at 7:16
  • @DominicCronin good point, I see only now that it is indeed a Component Template and not a compound TBB, that is a more serious typo I'll report it. I also think the sentance "invoking the TBB" might be slightly misleading, I'll see what our tech writer can do to change that – Bart Koopman Oct 18 '17 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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