Change ‘The Form Could Not Be Submitted..’ Message In Dynamics 365 Portal

Requirement

In my previous article, we discussed how to implement a custom JavaScript validation message. Now, let’s say we want to change the title of the validator.

Javascript validation message

Solution

To accomplish the above requirement, the first thing I tried to check was its element, using the inspect tool. This way, I can use jQuery to change this message, and here is what I got from the inspect tool.

Inspect tool

You can see in the above screenshot that the div has the ValidationSummaryEntityFormControl_EntityFormView ID so I used the following code-

$('#ValidationSummaryEntityFormControl_EntityFormView').attr("aria-label", "Preferred appointment cannot be submitted due to the reasons below:");

However, I was not able to see any changes in the validation message and then, I tried to check again using inspect. I found that even though this label was changed, the validator title was the same.

Validator title

Next, I tried the following code in the console.

$('h4.validation-header').text("Appointment preferences cannot be submitted due to the reasons below:");

And, I was able to see changes in the validation title as well, like the following.

Console

But when I used this code under entity form and checked, it was still showing the old title. Finally, I found that the above heading element is generated at runtime only. So, finally, I was able to use a set interval method like the following.

// Change form validation label
setInterval(function () {
   if ($('h4.validation-header')) {
      $('h4.validation-header').text("Appointment preferences cannot be submitted due to the reasons below:");
   }
}, 1000);

Hope it will help someone, feel free to share if you know the more efficient method to implement it.

Stay tuned for more Dynamics 365 content.


Similar Articles
HIMBAP
We are expert in Microsoft Power Platform.