2

Recently we upgrade Tridion platform to 8.5 and DXA from 1.3 to 1.8. Although everything seemed OK at the beginning, we are having issues with model mapping of Embedded fields. All the Embedded models are just NULL with in the parent object. After struggling for few days, we found that renaming embedded field's root element to same of its parent(In our case its "Content") solved the issue. But We have some existing schema with multiple embedded fields and we can't rename both embedded fields to "Content". Tried specifying Semantic property to the embeded models but still no joy :(

[SemanticEntity(Vocab = CoreVocabulary, EntityName = "ContentType", Prefix = "s")]

I tried debugging the DXA code and I could see an issue with mapping on DefaultModelBuilder -> MapFieldValues() -> MapEmbeddedFields() -> GetFieldFromSemantics(). The xpath is always taking Content\Content\ insted of Content\ContentType\ even after specifying the the entity name on Semantic property.

To me, this seems to be a mapping issue with DXA 1.8. Can someone confirm? Is there any other way to address the embedded mapping issue?

EDIT Here is the complete schema.json

 {
    "Id": 30241,
    "RootElement": "Content",
    "Fields": [{
            "Name": "title",
            "Path": "/Content/title",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "title"
                }
            ],
            "Fields": []
        }, {
            "Name": "description",
            "Path": "/Content/description",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "description"
                }
            ],
            "Fields": []
        }, {
            "Name": "first_name_label",
            "Path": "/Content/first_name_label",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "first_name_label"
                }
            ],
            "Fields": []
        }, {
            "Name": "first_name_placeholder",
            "Path": "/Content/first_name_placeholder",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "first_name_placeholder"
                }
            ],
            "Fields": []
        }, {
            "Name": "first_name_required_message",
            "Path": "/Content/first_name_required_message",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "first_name_required_message"
                }
            ],
            "Fields": []
        }, {
            "Name": "last_name_label",
            "Path": "/Content/last_name_label",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "last_name_label"
                }
            ],
            "Fields": []
        }, {
            "Name": "last_name_placeholder",
            "Path": "/Content/last_name_placeholder",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "last_name_placeholder"
                }
            ],
            "Fields": []
        }, {
            "Name": "last_name_required_message",
            "Path": "/Content/last_name_required_message",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "last_name_required_message"
                }
            ],
            "Fields": []
        }, {
            "Name": "email_label",
            "Path": "/Content/email_label",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "email_label"
                }
            ],
            "Fields": []
        }, {
            "Name": "email_placeholder",
            "Path": "/Content/email_placeholder",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "email_placeholder"
                }
            ],
            "Fields": []
        }, {
            "Name": "email_required_message",
            "Path": "/Content/email_required_message",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "email_required_message"
                }
            ],
            "Fields": []
        }, {
            "Name": "subscription_types",
            "Path": "/Content/subscription_types",
            "IsMultiValue": true,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "subscription_types"
                }
            ],
            "Fields": [{
                    "Name": "title",
                    "Path": "/Content/subscription_types/title",
                    "IsMultiValue": false,
                    "Semantics": [{
                            "Prefix": "tri",
                            "Entity": "SubscriptionType",
                            "Property": "title"
                        }
                    ],
                    "Fields": []
                }, {
                    "Name": "description",
                    "Path": "/Content/subscription_types/description",
                    "IsMultiValue": false,
                    "Semantics": [{
                            "Prefix": "tri",
                            "Entity": "SubscriptionType",
                            "Property": "description"
                        }
                    ],
                    "Fields": []
                }, {
                    "Name": "newsletter_id",
                    "Path": "/Content/subscription_types/newsletter_id",
                    "IsMultiValue": false,
                    "Semantics": [{
                            "Prefix": "tri",
                            "Entity": "SubscriptionType",
                            "Property": "newsletter_id"
                        }
                    ],
                    "Fields": []
                }
            ]
        }, {
            "Name": "summary",
            "Path": "/Content/summary",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "summary"
                }
            ],
            "Fields": []
        }, {
            "Name": "gdpr_consent_text_pm",
            "Path": "/Content/gdpr_consent_text_pm",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "gdpr_consent_text_pm"
                }
            ],
            "Fields": []
        }, {
            "Name": "cta_text",
            "Path": "/Content/cta_text",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "cta_text"
                }
            ],
            "Fields": []
        }, {
            "Name": "thank_you_link",
            "Path": "/Content/thank_you_link",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "thank_you_link"
                }
            ],
            "Fields": []
        }, {
            "Name": "error_link",
            "Path": "/Content/error_link",
            "IsMultiValue": false,
            "Semantics": [{
                    "Prefix": "tri",
                    "Entity": "Content",
                    "Property": "error_link"
                }
            ],
            "Fields": []
        }
    ],
    "Semantics": [{
            "Prefix": "tri",
            "Entity": "Content"
        }
    ]
}

And sematic entity is always content. It is supposed to be SubscriptionType, isn't it?

enter image description here

Any help appreciated!

Issue Resolved

As per Rick's comment, For some reason publish settigns was pointing to old version of DXA and after registering embedded type everthign worked like charm!

  • Is your Embeeded class inheriting from ViewModel? (or EntityBase or whatever class that is DXA's aware...) – Jaime Santos Alcón Mar 13 at 12:54
  • Please provide more info. How are your (embedded) View Model Types defined? What are the root element/type names of your CM Schemas what are the field XML names? Note that the “root element name” of an embedded Schema is actually a type name. That is: you won’t see that name reflected in an XPath. Please have a look (and share) the BinaryData/xyz/system/mappings/schemas.json and find the relevants Schemas there. Also have a look at the DXA log file with DEBUG logging enabled. – Rick Pannekoek Mar 13 at 13:00
  • Is the embedded View Model Type registered? See docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v7.1.1/… – Rick Pannekoek Mar 13 at 13:01
  • Also try republishing the “Publish Settings” Page (to ensure that schemas.json is up-to-date) – Rick Pannekoek Mar 13 at 13:04
  • In the past, there was an issue that prefixes for embedding and embedded View Model Type annotations should be the same. See also tridion.stackexchange.com/questions/17987/… (note that the question is about retrofit mode which you probably don't use, but it mentions use of prefixes). – Rick Pannekoek Mar 13 at 13:29
1

The problem seems to be that your schemas.json is incomplete.

In DXA 1.7, the semantic mapping was refactored (in order to introduce refrofit mode). As part of that refactoring, mapping of embedded fields was changed. Since DXA 1.7, you should see multiple semantics for embedded fields in schemas.json: one representing the embedded schema and one representing the embedding schema (and even more if you have multiple levels of embedding).

This change in semantic mapping both on CM side and in the Web Application is supposed to be backwards compatible (no changes to your View Model types should be needed), but you do have to ensure that you republish schemas.json by means of republishing the ”Publish Setting” Page after upgrading to DXA 1.7 or higher.

You are saying that you don’t see multiple semantics for embedded schema fields in schemas.json, even after republishing the “Publish Settings” Page. That makes me wonder whether you have properly upgraded your DXA on CM-side.

| improve this answer | |
  • Hi Rick Pannekoek, it was my bad! Included complete schema for the component now. now. I don't think there is an issue with schema.json. Could you please confirm how do I need to specify the semantic decorators on viewmodel class for both embedded and embedding models? – ragmn Mar 14 at 18:24
  • I do think there is an issue with your schemas.json. Check, for example, how the /Content/subscription_tyoes/title field is defined. It has only one semantics (SubscriptionType:title), but should have two (also Content:title). – Rick Pannekoek Mar 15 at 17:56
  • is there a way to check if DXA 1.8 on CM side is properly updated? What/where do you think could be the issue? – ragmn Mar 16 at 9:30
  • Thanks @Rick Pannekoek! Publish settigns was pointing to old version of DXA and after registering embedded type everthign worked magically! :) – ragmn Mar 16 at 16:06

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.