Skip to main content

Notifications

Announcements

No record found.

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.

  • Wahaj Rashid Profile Picture
    Wahaj Rashid 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

  • Wahaj Rashid Profile Picture
    Wahaj Rashid 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

  • Kiran Santhosh Profile Picture
    Kiran Santhosh 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

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 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
    Kiran Santhosh 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

  • LuHao Profile Picture
    LuHao 40,876 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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,329 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans