Table change records encapsulate the changes made to a specific table at a certain point in time. Employing APIs allows developers to programmatically interact with these records within an application, making the process of record change monitoring much more streamlined and automatic.
Available APIs offer different capabilities. The Common Data Service (CDS) Web API presents RESTful protocols to perform CRUD (Create, Read, Update, Delete) operations, allowing the developers to handle data and metadata from the CDS environment.
Reading API change records:
To detect changes in a table, the RetrieveEntityChanges
function is widely used. This function queries for changes recorded in an entity, enabling developers to track modifications.
Here is a simple example of how RetrieveEntityChanges
can be used:
// API request
const req = new XMLHttpRequest();
req.open("GET", encodeURI(`/api/data/v9.0/RetrieveEntityChanges(EntityName='account',ColumnSet=@p1,Token=@p2)?@p1={'AllColumns':true}&@p2='null'`), true);
// Sending the request
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.send();
Here ‘account’ is the table name for which the changes are being tracked, ‘AllColumns’ signifies retrieval of all columns, and ‘null’ signifies that there is no paging token as this is the initial retrieval.
Additionally, the RetrieveEntityChangeRequest
function can be used as follows:
// Create the data context
var svcContext = new ServiceContext(_serviceProxy);
// Define the fetch query
string fetchXml = "
"
"
"
"";
// Create and execute the retrieve entity changes request
var request = new RetrieveEntityChangesRequest
{
EntityName = "account",
RetrievalConditions = new RetrievalQuerySequence() { Sequence = fetchXml }
};
var response = (RetrieveEntityChangesResponse)_serviceProxy.Execute(request);
In above example, RetrieveEntityChangeRequest
is used to create a request to track changes related to the account
table. The RetrievalQuerySequence
property ensures retrieval of account
data according to the specified FetchXML query.
Remember, the right API for your task will depend on your project requirements and the specific data you need to interact with. Understanding how to read table change records using platform APIs is a crucial skill for passing your PL-400 Microsoft Power Platform Developer exam, and one that will be invaluable in your career as a developer.
Practice Test
True or False: The GetChanges() API function can be used to track changes made in a data table.
- True
- False
Answer: True
Explanation: The GetChanges() API function is used to identify changes made to a data table and is especially useful when dealing with complex change scenarios.
True or False: To use platform APIs, no programming knowledge is necessary.
- True
- False
Answer: False
Explanation: To use platform APIs effectively, joining and programming knowledge is necessary, which is commonly tested in PL-400 exam for Microsoft Power Platform Developer certification.
True or False: A ChangeSet in the GetChanges() API function represents a single change made to the records in a data table.
- True
- False
Answer: False
Explanation: A ChangeSet represents a group of changes, not a single change. It includes multiple changes made to the records during a particular state or condition.
In Platform APIs, which of the following action represents a change?
- a) Mapping
- b) Triggering
- c) Logging
- d) Deleting
Answer: d) Deleting
Explanation: In the context of platform APIs, deleting a record is considered as a “change.” Other actions like mapping, triggering and, logging can change the state of the data, but they are not regarded as changes in this context.
True or False: You can read table change records using platform APIs without accessing the underlying database.
- True
- False
Answer: True
Explanation: Yes, you can read change records using platform APIs without the need to directly access the underlying database. This abstraction is part of the benefits of using APIs.
To read table change records by using platform APIs, which programming language might be most commonly used?
- a) Python
- b) C#
- c) JAVA
- d) MATLAB
Answer: b) C#
Explanation: Microsoft’s Power Platform typically uses C# for such operations, but other languages could be used depending on the implementation.
True or False: A database administrator can use a ChangeSet to rollback changes made in a data table.
- True
- False
Answer: True
Explanation: A ChangeSet in platform API includes all changes, and can theoretically be used to rollback changes if the API and database support this functionality.
Which of the following fields are most likely to be included in a ChangeSet?
- a) The current value of all fields in a record
- b) The previous value of all fields in a record
- c) The user who made the change
- d) All of the above
Answer: d) All of the above
Explanation: A ChangeSet often includes current and previous values for tracking purposes, and the details of the user who made the changes for accountability.
True or False: The GetChanges() function can be used to track schema changes in a data table.
- True
- False
Answer: False
Explanation: The GetChanges() function is used for tracking changes to data within the table. For schema changes, a different system or function would be involved.
When using the GetChanges() API function, the changes are returned in which order?
- a) Ascending order
- b) Descending order
- c) Alphabetical order
- d) Random order
Answer: a) Ascending order
Explanation: Typically, the GetChanges() API function returns changes in ascending order – from the oldest change to the newest. However, this might depend on specific API implementation.
Interview Questions
Which function is used to retrieve a table change in Microsoft Power Platform?
The RetrieveMultiple function is used to retrieve a table change in Microsoft Power Platform.
What allows for retrieval of a collection of records from a table?
A Query Expression allows for the retrieval of a collection of records from a table.
What is the primary method for reading data in table change records through the Web API?
The primary method is sending HTTP requests using the GET method.
What is a Property in the context of reading table change records using platform APIs?
A Property is an attribute of a table change record and represents the data to be stored, retrieved, or changed.
What is a managed property in Microsoft Power Platform?
A managed property allows customization that can be performed based on whether the solution is managed or unmanaged.
What is the RESTful API used by Microsoft Power Platform for data management and manipulation?
The OData (Open Data Protocol) is the RESTful API used by Microsoft Power Platform for data management and manipulation.
Which API do you use to work with data in Power Apps?
The Common Data Service (CDS) Web API is used to work with data in Power Apps.
What method is used to update existing record (table change) via API?
The HTTP PATCH method is used to update existing record (table change) via API.
True or False? You can retrieve metadata about the attributes by retrieving EntityMetadata record using the RetrieveRequest.
True. You can retrieve metadata about the attributes by retrieving EntityMetadata record using the RetrieveRequest.
What is “ChangeType” in the context of reading table change records using platform APIs?
“ChangeType” is a property in the Change record (table change record) representing the type of change that was made – Create, Update, Delete, or None.
In Power Platform, What is the primary return format when utilizing Get method calls in the Web API?
The primary return format is JSON (JavaScript Object Notation).
Which API allows development against more than 200 Microsoft services including Microsoft Graph and Power Platform?
Microsoft Dataverse RESTful Web API allows development against more than 200 Microsoft services including Microsoft Graph and Power Platform.
Why would you use “Upsert” in the context of working with data through platforms APIs in Power Platform?
“Upsert” is used when you want to insert a record if it does not already exist, or to update the existing record.
What does Dataverse API operation RetrievePrincipalAccess do?
RetrievePrincipalAccess in Dataverse API retrieves the access rights a security principal (user or team) has to a record.
What does Prefer: odata.include-annotations=”*” HTTP request header do in Power Platform?
The Prefer: odata.include-annotations=”*” HTTP request header is used to control whether annotations, including computed properties and navigation properties, are returned in the response.