
Announcements
I have two different entities I need to grab data from in order to populate an attendance table. They are joined via two other entities. How do I go about getting my table populated. Here is the scenario:
Tables:
Course Enrollment - The three records I need here are course enrollment id and student id and academic period.
Academic Period - This is the look up to the academic period from the course enrollment.
Calendar - This has the academic period code that I get from the academic period table.
Calendar dates - This has all of the individual dates in the calendar (ie, 9/6/2023, 9/7/2023)
What I am trying to do is update an attendance table. I need the course enrollment id, student id, and the individual date fields, but they are coming from two different tables, plus I have to join the academic period and calendar tables to get to the calendar dates table.
I thought I could grab just the enrollment first:
Then grab the dates using a Fetch XML query:
But I keep getting an error with my XML.
Is this a good way to do it? Is there a better way?
I am using the below XML and it is successful when I plug it into Fetch XML builder but I am getting this error: Key property 'mshied_schoolcalendardateid' of type 'Microsoft.Dynamics.CRM.mshied_schoolcalendardate' is null. Key properties cannot have null values.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="mshied_schoolcalendardate">
<attribute name="mshied_startdatetime" alias="startdatetime" />
<link-entity name="mshied_schoolcalendar" from="mshied_schoolcalendarid" to="mshied_calendar" alias="sc">
<attribute name="mshied_academicperiod" alias="ap" />
<link-entity name="mshied_academicperiod" from="mshied_academicperiodid" to="mshied_academicperiod" alias="ap">
<attribute name="mshied_code" />
</link-entity>
</link-entity>
</entity>
</fetch>