Question 119 of 130 from exam PL-400: Microsoft Power Platform Developer

Question 119 of 130 from exam PL-400: Microsoft Power Platform Developer

Question

You need to use an alternate key for the data operations with the Dataverse table.

Here is the code:

KeyAttributeCollection collKey = new KeyAttributeCollection();
collKey.Add("emailaddress", "infor@cbindustries.com");
collKey.Add("businessphone", 1234-56-78");

Entity customer = new Entity("customer", collKey);
customer["firstname"] = "John";
customer["lastname"] = "Doe";

customer["jobtitle"] = "CTO";

UpsertRequest request = new UpsertRequest()
{ Target = customer };

UpsertResponse response = (UpsertResponse)service.Execute(request);

Please select all data operations that this code can execute.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E. F.

Correct Answers: B and E

All Dataverse tables have a primary key.

A primary key is a GUID.

When you read or write records, it is not efficient to search for GUID first and then access the record.

Therefore, it is more convenient and productive to have another unique key for the record - an alternate key.

You can use any column or combination of columns that uniquely identify the records as an alternate key.

An alternate key can be used as a substitute for a primary key.

The alternate keys are important for integration between Dataverse records and external sources.

External databases can use an alternate key for the records access.

When you work with Dataverse records and do not know if the record exists or not, the best way is to use the Upsert operation.

The Upsert is a combination of Update and Insert.

Or if you use this in a code - the UpsertRequest()

It is the combination between CreateRequest() and UpdateRequest()

The UpsertRequest has the performance overhead.

Therefore, if you know that a record does not exist, use the CreateRequest.

Or it is present in the table - use the UpdateRequest()

In the code, we use an alternate key as a combination of the two fields: email address and business phone (Number 1) to create a Customer table object (Number 2)

If the record in the Customer table exists for the values of the alternate key ("infor@cbindustries.com" and "1234-56-78”), the UpsertRequest() (Number 4) will update the values of the firstname, lastname, and jobtitle columns with “John,” “Doe,” and “CTO” (Number 3)

If there is no record in the Customer table for the values of the alternate key ("infor@cbindustries.com" and "1234-56-78”), the UpsertRequest() will create a new record using the values for the alternate key and the firstname, lastname, and jobtitle columns.

All these operations will be performed during the execution of the request (Number 5)

The response (Number 6) has RecordCreated property.

If a request creates a new record, the RecordCreated value is true.

Otherwise, the value is false for the record update.

Co nN OO MO SPW PY —

eo)

KeyAttributeCollection collKey = new KeyAttributeCollection();
collKey.Add("emailaddress", "“infor@cbindustries.com");

collKey.Add("businessphone", 1234-56-78");

Entit

customer = new Entity("customer", collKey);

customer["lastname"] =

customer["jobtitle"] = "CTO";

UpsertRequest request = new|UpsertRequest () 0

{ Target = customer };

G is)
Upse -tnesponsel TE AEE] = |(UpsertResponse) service. Execute( request);

Options B and E are correct because the code uses the Upsert operation.

The Upsert is a combination of Update and Insert (or create).

All other options are incorrect.

For more information about Dataverse alternate keys and Upsert, please visit the below URLs: