Free PL-400 Exam Braindumps (page: 21)

Page 20 of 100

A company requires a plug-in that makes multiple requests to an external web service. The plug-in must not time out when the web service has issues or is slow to respond.

You need to create the plug-in.

What should you do?

  1. Assign the IOrganizationService object to a member variable.
  2. Register the plug-in to run synchronously.
  3. Register the plug-in step once for each web service request.
  4. Set the HTTP connection KeepAlive property to false.

Answer(s): B



HOTSPOT (Drag and Drop is not supported)
Field technicians use a canvas app to update Microsoft Dataverse data. The app is designed to work when it is not connected to the internet.

The app requires a plug-in to apply business logic after records are updated. Unhandled exceptions must not prevent records from saving or syncing.

You need to register the plug-in step to apply the business logic.

Which values should you use for each plug-in step setting? To answer, select the appropriate options in the answer area.

NOTE: Each correct selection is worth one point.

  1. See Explanation section for answer.

Answer(s): A

Explanation:



Box 1: Offline
Plug-in deployment

Deployment
* Server
The plug-in will run on the Dataverse server.

* Offline
The plug-in will run within the Dynamics 365 for Outlook client when the user is in offline mode.

Box 2: PostOperation
Plug-in step event

"The app requires a plug-in to apply business logic after records are updated."


Reference:

https://learn.microsoft.com/en-us/power-apps/developer/data-platform/register-plug-in



HOTSPOT (Drag and Drop is not supported)
You are creating an application using the Microsoft Dataverse SDK for .NET.

A record must be created by using the column types of lookup and choices.

You need to set the record's column values.

Which attribute type should you use? To answer, select the appropriate options in the answer area.

NOTE: Each correct selection is worth one point.

  1. See Explanation section for answer.

Answer(s): A

Explanation:



Box 1: EntityReference
Lookup

Associate table rows on create
You can associate any new row with an existing row when you create it in the same way you would when updating it. You must use an EntityReference to set the value of a lookup column (attribute).

This lookup assignment is the same for both early and late-bound styles.

//Use Entity class with entity logical name
var account = new Entity("account");

// set attribute values
//string primary name
account["name"] = "Sample Account";

Guid primarycontactid = new Guid("e6fa5509-2582-e811-a95e-000d3af40ae7");

account["primarycontactid"] = new EntityReference("contact", primarycontactid);

//Create the account
Guid accountid = svc.Create(account);

Box 2: OptionSetValueCollection
Choices

Dataverse, Choices columns
Customizers can define a column that allows selection of multiple options. The MultiSelectPicklistAttributeMetadata class defines a column type that inherits from the EnumAttributeMetadata class. Just like the PicklistAttributeMetadata class, this column includes an OptionSetMetadata.Options property that contains the valid options for the column. The difference is that the values you get or set are an *OptionSetValueCollection* type that contains an array of integers representing the selected options. Formatted values for this column are a semi-colon separated string containing the labels of the selected options.

Note: Create choices with code
The easiest way to create choices is to use the column editor in the customization tools. More information: How to create and edit columns

But if you need to automate creation of this kind of column you can use C# code like the following with the SDK for .NET that creates choices to allow choices of outdoor activities to the contact table. More information: Create columns

private const int _languageCode = 1033; //English

MultiSelectPicklistAttributeMetadata outDoorActivitiesAttribute = new MultiSelectPicklistAttributeMetadata()
{
SchemaName = "sample_OutdoorActivities",
LogicalName = "sample_outdooractivities",
DisplayName = new Label("Outdoor activities", _languageCode),
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
Description = new Label("Outdoor activities that the contact likes.", _languageCode),
OptionSet = new OptionSetMetadata()
{
IsGlobal = false,
OptionSetType = OptionSetType.Picklist, // Picklist
Options = {
new OptionMetadata(new Label("Swimming",_languageCode),1),
new OptionMetadata(new Label("Hiking",_languageCode),2),
new OptionMetadata(new Label("Mountain Climbing",_languageCode),3),
new OptionMetadata(new Label("Fishing",_languageCode),4),
new OptionMetadata(new Label("Hunting",_languageCode),5),
new OptionMetadata(new Label("Running",_languageCode),6),
new OptionMetadata(new Label("Boating",_languageCode),7),
new OptionMetadata(new Label("Skiing",_languageCode),8),
new OptionMetadata(new Label("Camping",_languageCode),9)}
}
};

CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest
{
EntityName = "contact",
Attribute = outDoorActivitiesAttribute
};

var response = (CreateAttributeResponse)service.Execute(createAttributeRequest);


Reference:

https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/entity-operations-create
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/multi-select-picklist?tabs=webapi#create-choices-with-code



A company requires a plug-in that makes multiple requests to an external web service. The plug-in must not time out when the web service has issues or is slow to respond.

You need to create the plug-in.

What should you do?

  1. Send requests to use multiple threads.
  2. Register the plug-in to run synchronously.
  3. Register the plug-in step once for each web service request.
  4. Set the HTTP connection timeout value explicitly to limit how long each connection can remain open.

Answer(s): D

Explanation:

Correct:
* Set the HTTP connection KeepAlive property to false.

* Set the HTTP connection timeout value explicitly to limit how long each connection can remain open

Incorrect:
* Assign the IOrganizationService object to a member variable.
* Register the plug-in step once for each web service request.
* Register the plug-in to run synchronously.
* Send requests to use multiple threads

Note:
* Set the HTTP connection KeepAlive property to false
Set KeepAlive to false when interacting with external hosts in a plug-in

Category: Performance
Impact potential: High

Symptoms
If a plug-in makes external web requests and is trying to use KeepAlive on a closed connection, the plug-in will ultimately fail to execute the web request. If the plug-in is registered:

* Synchronously, users may experience:
Unresponsive model-driven apps
Slow client interactions
The browser stops responding

* Asynchronously, plug-in executions may take an extended period of time before failing.

Guidance
In HTTP 1.1, all connections are considered persistent (KeepAlive is true) unless declared otherwise. Due to the fact that plug-ins run in isolation, the Sandbox service translates into them being short-lived executions that generally would not benefit from KeepAlive. To avoid problems with connecting to external services we recommend disabling KeepAlive within plug-ins. If your specific external service would benefit from using persistent sessions for performance reasons, actively send a KeepAlive at an interval of half the idle timeout (30 seconds) to keep the connection from closing.

Problematic patterns
In order to override the default value of KeepAlive for the non-WCF interactions, the approach should be taken to leverage HttpWebRequest to perform the interactions with the web server, but first setting the KeepAlive property to false.

* Set the HTTP connection timeout value explicitly to limit how long each connection can remain open


Power Apps Dataverse, Set Timeout when making external calls in a plug-in

Category: Performance

Impact potential: High

Symptoms
If a plug-in makes external web requests that fail to respond quickly, the plug-in will wait for the full default timeout period before failing. This duration may cause a long transaction that can effect other operations. If the plug-in is registered:

Synchronously, users may experience:

Unresponsive model-driven apps
Slow client interactions
The browser stops responding
Asynchronously, plug-in executions may take an extended period of time before failing.


Guidance
The default timeout value for .Net Http clients is 100 seconds, just 20 seconds short of the time available for the plug-in to complete. It is best to establish an expected baseline time that a calling service will respond. The longer it exceeds this normal response time, the higher the probability it will ultimately fail. As a performance best practice, it is best to fail quickly rather than allow the default timeout period to expire. You should control the period that your call to the external service will wait.

The timeout value you should set will depend on the service. For example, if you can monitor the performance of the service you may determine a duration where 99.999% of requests succeed and set your timeout period to that duration with a few seconds buffer. This will prevent the occasional outliers from having an inordinate impact on the performance of your plug-in.

If you are using System.Net.Http.HttpClient Class, you can set the Timeout value explicitly, as shown in this example setting the timeout to 15 seconds.

C#

Copy
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromMilliseconds(15000); //15 seconds
client.DefaultRequestHeaders.ConnectionClose = true; //Set KeepAlive to false

Etc.


Reference:

https://learn.microsoft.com/en-us/power-apps/developer/data-platform/best-practices/business-logic/set-keepalive-false-interacting-external-hosts-plugin
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/best-practices/business-logic/set-timeout-for-external-calls-from-plug-ins






Post your Comments and Discuss Microsoft PL-400 exam with other Community members:

PL-400 Exam Discussions & Posts