Use Case: Export Course Management Data
We will create a Custom Connector to export data from the following Dataverse tables (Refer Dataverse Datamodel):
- Courses: Stores course information (e.g., Course Name, Description, Start Date).
- Students: Stores student details (e.g., Name, Email, Enrollment Status).
- Instructors: Stores instructor details (e.g., Name, Email, Assigned Courses).
The connector will support:
- Retrieving all courses.
- Retrieving students enrolled in a course.
- Retrieving instructors assigned to a course.
Step-by-Step Implementation
1. Set Up Your Dataverse Tables
Ensure your Dataverse data model includes:
- Courses:
- Fields:
CourseName
,Description
,StartDate
,CourseID
(unique identifier).
- Fields:
- Students:
- Fields:
StudentName
,Email
,EnrollmentStatus
,CourseID
(lookup to Courses).
- Fields:
- Instructors:
- Fields:
InstructorName
,Email
,CourseID
(lookup to Courses).
- Fields:
Populate sample data to test the connector functionality.
2. Expose Dataverse Data as an API
- Enable Dataverse Web API:
- Dataverse data is accessible via the Dataverse Web API.
- Use OData queries to filter and retrieve specific data.
- Example API Endpoints:
- Get all courses:plaintextCopy code
GET https://<environment>.api.crm.dynamics.com/api/data/v9.2/courses
- Get students by course:plaintextCopy code
GET https://<environment>.api.crm.dynamics.com/api/data/v9.2/students?$filter=CourseID eq <CourseID>
- Get instructors by course:plaintextCopy code
GET https://<environment>.api.crm.dynamics.com/api/data/v9.2/instructors?$filter=CourseID eq <CourseID>
- Get all courses:plaintextCopy code
- Authentication:
- Use OAuth 2.0 with Azure Active Directory to authenticate API calls.
3. Create the Custom Connector
- Access Power Platform:
- Go to Power Apps > Data > Custom Connectors.
- Start a New Connector:
- Click + New Custom Connector > Create from Blank.
- Name the connector (e.g.,
CourseManagementExport
).
- Set Up General Information:
- Host: Add your Dataverse environment URL (e.g.,
https://<environment>.api.crm.dynamics.com
). - Base URL: Use
/api/data/v9.2
.
- Host: Add your Dataverse environment URL (e.g.,
- Configure Security:
- Go to the Security tab and select OAuth 2.0.
- Provide the following:
- Client ID and Client Secret from your Azure AD App Registration.
- Token URL:
https://login.microsoftonline.com/<tenantID>/oauth2/v2.0/token
. - Scope:
https://<environment>.api.crm.dynamics.com/.default
.
4. Define Actions in the Connector
- Add Action: Get Courses
- Go to the Definition tab.
- Click + New Action and configure:
- Summary: Fetch all courses.
- Operation ID:
GetCourses
. - Request:
- Method:
GET
. - URL:
/courses
.
- Method:
- Response:
- Add a sample response:jsonCopy code
[ { "CourseID": "1", "CourseName": "Math 101", "Description": "Basic Mathematics", "StartDate": "2024-01-15" } ]
- Add a sample response:jsonCopy code
- Add Action: Get Students for a Course
- Configure another action:
- Summary: Fetch students for a specific course.
- Operation ID:
GetStudentsByCourse
. - Request:
- Method:
GET
. - URL:
/students?$filter=CourseID eq {CourseID}
. - Add a parameter for
CourseID
.
- Method:
- Response:
- Add a sample response:jsonCopy code
[ { "StudentName": "John Doe", "Email": "john.doe@example.com", "EnrollmentStatus": "Active" } ]
- Add a sample response:jsonCopy code
- Configure another action:
- Add Action: Get Instructors for a Course
- Configure another action:
- Summary: Fetch instructors for a specific course.
- Operation ID:
GetInstructorsByCourse
. - Request:
- Method:
GET
. - URL:
/instructors?$filter=CourseID eq {CourseID}
. - Add a parameter for
CourseID
.
- Method:
- Response:
- Add a sample response:jsonCopy code
[ { "InstructorName": "Jane Smith", "Email": "jane.smith@example.com" } ]
- Add a sample response:jsonCopy code
- Configure another action:
5. Test the Custom Connector
- Go to the Test tab in the Custom Connector.
- Enter sample parameters (e.g.,
CourseID
). - Verify the response:
- Check that the data is retrieved correctly from Dataverse.
6. Integrate the Connector
- In Power Automate:
- Use the connector to export data automatically.
- Example: Export student and instructor data to a SharePoint list or email as a CSV.
- In Power Apps:
- Use the connector as a data source to display or manipulate course data in Canvas or Model-Driven Apps.