PL-400 Exam QuestionsBrowse all questions from this exam

PL-400 Exam - Question 312


Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.

After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.

A company requires custom validation when users save form records that use a synchronous plug-in.

If validation fails, a message that explains how to resolve the issue must be displayed on the form to the user.

You need to implement the custom validation.

Solution: Throw a custom exception with the message.

Does the solution meet the goal?

Show Answer
Correct Answer: B

To implement custom validation in a synchronous plug-in and display a message to the user if validation fails, the appropriate approach is to throw an InvalidPluginExecutionException with the custom message, not a custom exception. Throwing an InvalidPluginExecutionException ensures that the message is properly communicated to the user within the context of the application's form.

Discussion

7 comments
Sign in to comment
NNNT
Dec 4, 2023

The Correct Answer Should be A. Yes To achieve the goal of displaying a user-friendly message on the form when validation fails, you should consider using the OrganizationServiceContext.ThrowInvalidPluginException method with a custom error message.

PY12396
Feb 6, 2024

I think the original answer is correct, because we need a custom message not a custom exception

KucaStonojkaOption: A
Nov 21, 2024

Throwing a custom exception with a message is an effective way to perform custom validation in a synchronous plug-in for Dynamics 365. This approach allows you to interrupt the save operation and display a clear and user-friendly message on the form. When the validation fails, the plug-in can throw an InvalidPluginExecutionException or a custom exception, passing the validation error message. Example: throw new InvalidPluginExecutionException("Validation failed: Please provide the required information."); This exception halts the operation and displays the message to the user directly on the form, allowing them to correct the issue before proceeding.

FCTopics
May 17, 2024

Original answer is correct Solution: Throw an InvalidPluginExecutionException with the message. To show a custom message you should use InvalidPluginExecutionException no a Custom Exception

rp2Option: A
Jan 7, 2025

It should be yes

Juan0414Option: A
Mar 6, 2025

InvalidPluginExecutionException is considered a custom exception (You can add a custom message and details), so Yes

itmaxuser
Apr 15, 2025

InvalidPluginExecutionException is not a custom exception — it's a built-in exception used for exactly this purpose.

hulendarOption: B
Apr 10, 2025

InvalidPluginExecutionException is not custom exception

itmaxuserOption: B
Apr 15, 2025

In Microsoft Dataverse (Dynamics 365): 🔴 Custom exceptions (e.g., your own MyValidationException) Will not display a friendly error message to the user. Instead, the platform will catch it and show a generic or technical error, or log it as an unhandled exception. The message is not reliably shown on the form or may even be hidden completely. InvalidPluginExecutionException Is the only supported way to throw an error from a plug-in that: Cancels the operation And displays the message directly to the user on the form It integrates with the platform’s error handling UI.