locked
How to remove the unwanted error details in the exception message? RRS feed

  • Question

  • Hi All,

    Can any one please help me to resolve the following:

    I have written a plug-in to validate the attachments for couple of entities in my CRM organization. The validations are working as expected. When the validation fails, the exception message is showing some unwanted error details to the user. How can I remove the unwanted messages/customize the message in exception window? Please find below for Exception Message.

    Here is the code:

                    //try
                //{
                //}
                    if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                    {
                        Entity entity = (Entity)context.InputParameters["Target"];
                        string fileName = string.Empty;
                        string fileType = string.Empty;
                        string regardingObjectName = string.Empty;

                        fileName = entity.GetAttributeValue<string>("filename");
                        fileType = entity.GetAttributeValue<string>("mimetype");

                        EntityReference regardingObj = entity.GetAttributeValue<EntityReference>("objectid");
                        regardingObjectName = regardingObj.LogicalName.ToString();

                        if (regardingObj.LogicalName.ToString() == "new_entity1" && fileName != null)
                        {
                            string filenameSub = fileName.Substring(0, 4);

                            if (fileType != "image/jpeg")
                            {
                                throw new InvalidPluginExecutionException("File Type invalid. Please upload only JPEG file");
                            }

                            else if (filenameSub.ToLower() != "new_")
                            {
                                throw new InvalidPluginExecutionException("File Name should start with 'new_'");
                            }
                        }

                        else if (regardingObj.LogicalName.ToString() == "new_entity2")
                        {
                            if (fileType != "image/jpeg")
                            {
                                throw new InvalidPluginExecutionException("File Type invalid. Please upload only JPEG file");
                            }
                        }
                    }

                //catch (FaultException<OrganizationServiceFault> ex)
                //{
                //    throw new InvalidPluginExecutionException("An error occurred in the Attachment Validation plug-in: " + ex.Message);
                //}

                //catch (Exception ex)
                //{
                //    tracingService.Trace("AttachmentValidation: {0}" + ex.ToString());
                //    throw;
                //}

    Thanks,

    Sri

    Tuesday, September 1, 2015 1:24 AM

All replies

  • Hello,

    You would not be able to remove that information.


    Dynamics CRM MVP
    My blog

    Tuesday, September 1, 2015 6:54 AM
    Moderator
  • Hi Andrii,

    Thanks for the reply. So, there is no way we could achieve it?

    And also, why this message is shown only for notes?

    Thanks & Regards,

    Sri

    Tuesday, September 1, 2015 7:04 AM
  • Hi Andrii,

    Thanks for the reply. So, there is no way we could achieve it?

    And also, why this message is shown only for notes?

    Thanks & Regards,

    Sri


    Regarding why I believe it is a good question to Microsoft but I believe this is because Microsoft haven't changed notes upload form since CRM 2011.

    Dynamics CRM MVP
    My blog

    Tuesday, September 1, 2015 7:07 AM
    Moderator