web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How can I show custom error message on export to excel

(0) ShareShare
ReportReport
Posted on by 5

I am trying to show an error message on Export to Excel of any entity. But I am getting the following error message, and unable to change what is being shown in the error popup.

8867.pastedimage1596697481306v1.png

Please let me know if there is any way to show custom error message from plugins on export to excel action.

This is an urgent requirement, appreciate if someone can help me with the same.

I have the same question (0)
  • LuHao Profile Picture
    40,890 on at
    RE: How can I show custom error message on export to excel

    Hi Kiran,

    Please check if there are two columns with the same label name.

    If so, we have to change one field display name of the duplicate name columns.

    pastedimage1596699774734v1.png

    Please refer to https://community.dynamics.com/crm/b/exploringdynamics365/posts/failed-to-generate-excel-an-error-occurred

  • Kiran Santhosh Profile Picture
    5 on at
    RE: How can I show custom error message on export to excel

    Hi Hao,

    I am trying to add a validation on export to excel action, but I am unable to show custom message on the same. I need to show a custom error when someone clicks on the Export To Excel button.

    Thanks and Regards

    Kiran S

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at
    RE: How can I show custom error message on export to excel

    Hi Kiran,

    There is no simple way to show a custom validation message here.

    However, there are 2 ways to do validation on export (nothing straight forward):

    1. Override Export to Excel button and in your custom JS function do the validation.
    2. Register a plugin on Retrieve Multiple message and do your validation in Plugin. If validation fails, you can throw an exception with custom message, like:

    throw new InvalidPluginExecutionException("Message here....");

    Please note there is no Export to Excel message available to register a a plugin,you have to use RetrieveMultiple message instead. To distinguish, between and Export Retrieve Multiple, see following thread:

    https://stackoverflow.com/questions/36471302/distinguish-page-load-and-export-to-excel-in-crm-2015

    Let me add extract from above article:

    • At page load, context depth is 1, while at export to excel, context depth is 2.
    • At page load, ParentContext is null, while at export to excel, ParentContext is not null and contains the following parameters: "View", "FetchXml", "LayoutXml", "QueryApi", "QueryParameters".
    • When export to excel, the message of ParentContext is clearly labeled as "ExportToExcel".

    Disclaimer: I did not test this solution, furthermore, this solution worked in CRM 2015, not sure if it works on Dynamics 365 v9.x.

    Finally, i would suggest to re-evaluate the requirement as it requires a lot of effort to just show a custom message.

    Feel free to discuss.

    Best,

    Wahaj

  • Kiran Santhosh Profile Picture
    5 on at
    RE: How can I show custom error message on export to excel

    Hi Wahaj,

    Thank you for your suggestions.

    I have already registered the plugin and I am able to prevent the export to excel if the validation.

    But I am not able to get the "throw new InvalidPluginExecutionException("error message...")" error message in my custom plugin to the error popup that is being shown on clicking the Export to Excel button.

    Thanks and Regards

    Kiran S

  • Wahaj Rashid Profile Picture
    11,321 on at
    RE: How can I show custom error message on export to excel

    Hi Kiran,

    This should work, can you make sure the part of your code *where you throw exception) is being executed?

    Looks like your code throws an un-handled exception (the one that you are not throwing), can you share the code?

    Best,

    Wahaj

  • Wahaj Rashid Profile Picture
    11,321 on at
    RE: How can I show custom error message on export to excel

    Hi Kiran,

    Did it work for you?

    Thanks,

    Wahaj

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 169

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 65

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 63 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans