Giter Club home page Giter Club logo

Comments (14)

meikelenboom avatar meikelenboom commented on June 9, 2024

I'm digging a little deeper and I find the following.

  • attachments work fine
  • activitymimeattachments do not

With activitymimeattachments the binary data is stored in CRM and in Azure Blob storage. The body field is not emptied / set to the new value.

Btw I'm working with v9.

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

Hi there,

Can you give a little bit more information here? Is it any kind of email attachments, like if you create a new email and add an attachment, does this happen? I remember seeing you mention email queues, is it only happening there?

The email attachments plugin is attached to run async after creation (i.e. the workflow service executes this by moving the data and then clearing out the record's binary data), so if there's any errors, you will see it in the "System Jobs" tab. If you could check there and see if you find anything?

Cheers.

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

Hi,

I've done very extensive testing and debugging and found that it happens on every e-mail (activitymimeattachments), not specifically related to queues.

It stores the data in blob storage, but the update to set the body field to the placeholder doesn't work. These line are the 'issue' in the Plugin.Create class:

entity.Attributes[GenericConstants.Constants[entity.LogicalName][GenericConstants.DocumentBodyAttributeKey]] = GenericConstants.EmptyBodyContent;
//If the plugin is running in async mode and is for attachment, we have to make a call to save the attachment.
if (context.Stage == CrmConstants.PostOperationStateNumber && entity.LogicalName == CrmConstants.AttachmentEntityName)
{
    service.Update(entity);
}

I've tested it with CRM online V8.2 and V9.0. And I've tested it with various options in async and synchronous mode.

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

I forgot about the System Jobs and found this error:

Plugin Trace:

[BinaryStorageOptions: BinaryStorageOptions.Plugin]
[d2e89545-de31-e611-942d-0050569079a0: BinaryStorageOptions.Plugin: Create of activitymimeattachment]



Error Message:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.ArgumentNullException: Value cannot be null.
Parameter name: s
   at System.IO.StringReader..ctor(String s)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at BinaryStorageOptions.Configuration.PluginStepConfigurationProvider..ctor(IOrganizationService organizationService, String configurationForEntityType, String unsecurePluginStepConfiguration, String securePluginStepConfiguration)
   at BinaryStorageOptions.Configuration.Factory.GetConfigurationProvider(IOrganizationService organizationService, String entityName, String unsecurePluginStepConfiguration, String securePluginStepConfiguration)
   at BinaryStorageOptions.Plugin.Create(IServiceProvider serviceProvider)Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ActivityId>013a6e68-f06c-46b1-80ec-ffa394f24dfb</ActivityId>
  <ErrorCode>-2147220891</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>OperationStatus</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">3</d2p1:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <d2p1:key>SubErrorCode</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>System.ArgumentNullException: Value cannot be null.
Parameter name: s
   at System.IO.StringReader..ctor(String s)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at BinaryStorageOptions.Configuration.PluginStepConfigurationProvider..ctor(IOrganizationService organizationService, String configurationForEntityType, String unsecurePluginStepConfiguration, String securePluginStepConfiguration)
   at BinaryStorageOptions.Configuration.Factory.GetConfigurationProvider(IOrganizationService organizationService, String entityName, String unsecurePluginStepConfiguration, String securePluginStepConfiguration)
   at BinaryStorageOptions.Plugin.Create(IServiceProvider serviceProvider)</Message>
  <Timestamp>2018-06-05T09:12:59.7866587Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource>PluginExecution</ExceptionSource>
  <InnerFault i:nil="true" />
  <OriginalException>Microsoft.Xrm.Sdk.InvalidPluginExecutionException
   at BinaryStorageOptions.Plugin.Create(IServiceProvider serviceProvider)
   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass14_3.&lt;Execute&gt;b__0()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
   at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
  <TraceText>
[BinaryStorageOptions: BinaryStorageOptions.Plugin]
[d2e89545-de31-e611-942d-0050569079a0: BinaryStorageOptions.Plugin: Create of activitymimeattachment]

</TraceText>
</OrganizationServiceFault>

However, I don't understand this error. I'm debugging with the profiler in the plugin registration tool and it doesn't give the same error. And I have some doubt if this error is actually related to the issue, as I can't reproduce it a the moment.

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

It's set correctly. That's why I think it's not from the error. But from the initial deployment.

In the meantime, I'm testing with an older onpremises environment to make sure I can debug properly. It doesn't give any errors, but the body is not set to the constant value.

So attachements are stored in blob storage, but not deleted from the database. It's not the same issue I started the issue with, but looks related.

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

Yes, that's exactly the case. I can now reproduce it in three environments v8.2 & v9 online en 2016 onpremises.

If you have any suggestions on what to try, I'm very willing to make changes and submit a pull request if I can get it to work.

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

I can confirm that I've tested it with post operation async (and other options as well)

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

Just to be sure it's not CRM, I've tested this code and that works;

entity["body"] = "IA==";

 if (context.Stage == 40 && entity.LogicalName == "activitymimeattachment")
{
    service.Update(entity);
}

from dynamics-crm-binary-storage-options.

meikelenboom avatar meikelenboom commented on June 9, 2024

I'm pretty lost. I've tried the code above, and that works. When I try the webapi to test the same, but from another api, it doesn't work.

It's all very inconsistent.

from dynamics-crm-binary-storage-options.

DawidPotgieter avatar DawidPotgieter commented on June 9, 2024

Hi there, sorry for the late response.

First off, the fact that the hard coded strings seem to make the debugging work, where the constants don't, well, that's a bizarre one that I don't have any ideas on.

However, I've just done some tests with clean installs, and I don't seem to have any issues when running this (haven't had a chance to test the 365 version yet, but I've been told it works fine there too). So, I would suggest as a last resort to remove the solution, and redo the install and setup steps, check if you still get an issue.

As a bit of history, what you are experiencing in that specific plugin in debug mode is exactly what I had, and I could never get it do work in debug/profiler mode. However, when the CRM workflow service executes that line, it works just fine, so I went with that. It seems that activitymimeattachments are "special" in some way, it doesn't work as consistently as other entities.

Looking back at this thread, it seems to have started off with getting an error when trying to read email attachments. Is that still an issue?
Then, onto the "not clearing out part", as I mentioned, that won't ever work in profiling/debug mode as far as I can remember. I can only think of a few more things to try :

  1. Re-install and try again without debugging
  2. Check to make sure that the user doing the work (plugin runs in user's context) has update permissions : Core Records/Activity/Write
  3. Hard code the constants as you have above. If that works, I don't see any issue using it like that, because the intent is exactly the same.

If none of those options fixes your problems, please let me know. I will then dig further and test it on dynamics 365 instance to see if I can help.

Cheers.

from dynamics-crm-binary-storage-options.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.