0

My data from component link in schema is not getting filled in Model DXA

In my class "Feed". Schema is with same name.

I am able to read the text fields and getting updated in Model automatically.

But component link data is null.

[SemanticEntity(Vocab = SchemaOrgVocabulary, EntityName = "Feed", Prefix = "s", Public = true)]
    public class Feed : EntityModel
    {
        public string Headline { get; set; }
        public string Url { get; set; }
        public int Limit { get; set; }
        public int Year { get; set; }
        public string testFeedText { get; set; }
        [SemanticProperty("s:externalcareer")]
        public List<ExternalCareer> ExternalCareer { get; set; }
    }

Data is getting updated in above model automatically but not updating in "ExternalCareer"

"ExternalCareer" is the component link. And multiple component link can be added.   

When I see source of component where data is filled against Feed schema. Below is the XML

<Feed xmlns="uuid:65b54eb0-92de-47cd-9c65-8ef54be672e1">
    <limit>10</limit>
    <year>2018</year>
    <readMoreText>Read more</readMoreText>
    <externalcareer xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:20-66542" xlink:title="Australia Career"></externalcareer>
    <externalcareer xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:20-66543" xlink:title="HG Career"></externalcareer>
    <testFeedText>Test Content</testFeedText>
</Feed>

And on preview the Json page data is as follows. Please advise.

"externalcareer": {
  "Name": "externalcareer",
  "Values": [],
  "NumericValues": [],
  "DateTimeValues": [],
  "LinkedComponentValues": [
    {
      "LastPublishedDate": "0001-01-01T00:00:00",
      "RevisionDate": "2019-05-14T13:42:58",
      "Schema": {
        "RootElementName": "ExternalCareer",
        "Id": "tcm:21-66534-8",
        "Title": "ExternalCareer"
      },
      "Fields": {
        "selectcountry": {
          "Name": "selectcountry",
          "Values": [],
          "NumericValues": [],
          "DateTimeValues": [],
          "LinkedComponentValues": [],
          "FieldType": 3,
          "CategoryName": "Test Career Countries",
          "CategoryId": "tcm:21-24802-512",
          "XPath": "tcm:Content/custom:ExternalCareer/custom:selectcountry",
          "KeywordValues": [
            {
              "Description": "Australia",
              "Key": "australia",
              "TaxonomyId": "tcm:21-24802-512",
              "Path": "\\Test Career Countries\\Australia",
              "ParentKeywords": [],
              "MetadataFields": {},
              "Id": "tcm:21-66520-1024",
              "Title": "Australia"
            }
          ]
        },
        "externalcareersdetailsbycountry": {
          "Name": "externalcareersdetailsbycountry",
          "Values": [],
          "NumericValues": [],
          "DateTimeValues": [],
          "LinkedComponentValues": [],
          "EmbeddedValues": [
            {
              "division": {
                "Name": "division",
                "Values": [ "GH/Cargo" ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[1]/custom:division",
                "KeywordValues": []
              },
              "url": {
                "Name": "url",
                "Values": [ "https://www.ssfdsffdijTest.nl/ " ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[1]/custom:url",
                "KeywordValues": []
              }
            }
          ],
          "EmbeddedSchema": {
            "RootElementName": "Content",
            "Id": "tcm:21-66541-8",
            "Title": "ExternalCareersDetailsByCountry"
          },
          "FieldType": 4,
          "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry",
          "KeywordValues": []
        }
      },
      "MetadataFields": {},
      "ComponentType": 1,
      "Categories": [],
      "Version": 2,
      "Id": "tcm:21-66542",
      "Title": "Australia Test Career"
    },
    {
      "LastPublishedDate": "0001-01-01T00:00:00",
      "RevisionDate": "2019-05-14T13:43:30",
      "Schema": {
        "RootElementName": "ExternalCareer",
        "Id": "tcm:21-66534-8",
        "Title": "ExternalCareer"
      },
      "Fields": {
        "selectcountry": {
          "Name": "selectcountry",
          "Values": [],
          "NumericValues": [],
          "DateTimeValues": [],
          "LinkedComponentValues": [],
          "FieldType": 3,
          "CategoryName": "Test Career Countries",
          "CategoryId": "tcm:21-24802-512",
          "XPath": "tcm:Content/custom:ExternalCareer/custom:selectcountry",
          "KeywordValues": [
            {
              "Description": "UK",
              "Key": "uk",
              "TaxonomyId": "tcm:21-24802-512",
              "Path": "\\Test Career Countries\\UK",
              "ParentKeywords": [],
              "MetadataFields": {},
              "Id": "tcm:21-66536-1024",
              "Title": "UK"
            }
          ]
        },
        "externalcareersdetailsbycountry": {
          "Name": "externalcareersdetailsbycountry",
          "Values": [],
          "NumericValues": [],
          "DateTimeValues": [],
          "LinkedComponentValues": [],
          "EmbeddedValues": [
            {
              "division": {
                "Name": "division",
                "Values": [ "GH/Cargo" ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[1]/custom:division",
                "KeywordValues": []
              },
              "url": {
                "Name": "url",
                "Values": [ "http://Test.co.uk/recruitment" ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[1]/custom:url",
                "KeywordValues": []
              }
            },
            {
              "division": {
                "Name": "division",
                "Values": [ "Travel" ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[2]/custom:division",
                "KeywordValues": []
              },
              "url": {
                "Name": "url",
                "Values": [ "https://Testtravelcareers.com/" ],
                "NumericValues": [],
                "DateTimeValues": [],
                "LinkedComponentValues": [],
                "FieldType": 0,
                "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry[2]/custom:url",
                "KeywordValues": []
              }
            }
          ],
          "EmbeddedSchema": {
            "RootElementName": "Content",
            "Id": "tcm:21-66541-8",
            "Title": "ExternalCareersDetailsByCountry"
          },
          "FieldType": 4,
          "XPath": "tcm:Content/custom:ExternalCareer/custom:externalcareersdetailsbycountry",
          "KeywordValues": []
        }
      },
      "MetadataFields": {},
      "ComponentType": 1,
      "Categories": [],
      "Version": 2,
      "Id": "tcm:21-66543",
      "Title": "UK Career"
    }
  ],
  "FieldType": 6,
  "XPath": "tcm:Content/custom:Feed/custom:externalcareer",
  "KeywordValues": []
}, "TestFeedText": {
  "Name": "TestFeedText",
  "Values": [ "Test Content" ],
  "NumericValues": [],
  "DateTimeValues": [],
  "LinkedComponentValues": [],
  "FieldType": 0,
  "XPath": "tcm:Content/custom:Feed/custom:TestFeedText",
  "KeywordValues": []
}

Regards,

1 Answer 1

0

I think the problem lies in the SemanticProperty annotation/attribute for the ExternalCareer property.

The default semantic mapping maps that (Pascal case) property to a CM field named externalCareer (camel case), but it seems your CM field is called externalcareer (lowercase).

You do have a SemanticProperty annotation mapping it to “externalcareer”, but that is in the “schema.org” vocabulary, instead of in the “Core Vocabulary”. The latter is normally used for mapping to CM fields.

See, for example: https://github.com/sdl/dxa-modules/blob/master/webapp-net/Core/Models/Entity/Teaser.cs

(That’s a rather extreme example of CM mapping, but it shows the use of the “Core Vocabulary” for that purpose)

1
  • Many thanks for your great help.
    – D.B.
    Commented May 15, 2019 at 16:16

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.