Dynamics-365-Workflow-Tools icon indicating copy to clipboard operation
Dynamics-365-Workflow-Tools copied to clipboard

CalculateRollup error, help please?

Open dnagirl opened this issue 2 years ago • 1 comments

I'm hoping I've just done something incorrect

Expected behavior and actual behavior.

Expected: parent roll-up field, pm_answeredcount is re-calculated Actual: workflow fails with this error for the user

'pm_PreliminaryRiskAssessment' entity doesn't contain attribute with Name = 'pm_answeredcount ' and NameMapping = 'Platform'. MetadataCacheDetails: ProviderType=Dynamic, StandardCache=True, IsLoadedInStagedContext = False, Timestamp=2961192, MinActiveRowVersion=2961192, MetadataInstanceId=46321125, LastUpdated=2022-02-01 05:47:23.243

and this comment in the log:

Sync workflow failed with error message - Exception type: Microsoft.Crm.CrmException Message: 'pm_PreliminaryRiskAssessment' entity doesn't contain attribute with Name = 'pm_answeredcount ' and NameMapping = 'Platform'. MetadataCacheDetails: ProviderType=Dynamic, StandardCache=True, IsLoadedInStagedContext = False, Timestamp=2961192, MinActiveRowVersion=2961192, MetadataInstanceId=46321125, LastUpdated=2022-02-01 05:47:23.243 at Microsoft.Xrm.RemotePlugin.Client.Interceptors.SandboxFabricClientTelemetryInterceptor.<>c__DisplayClass3_0.<Intercept>b__0() at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) at Microsoft.Xrm.RemotePlugin.Client.Interceptors.SandboxFabricClientTelemetryInterceptor.Intercept(IInvocation invocation, IExecutionContext context, SandboxFabricCallTracker sandboxFabricCallTracker) at Microsoft.Xrm.RemotePlugin.Client.Interceptors.SandboxFabricCodeUnitExecuteBaseInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.ISandboxFabricCodeUnitProxy.Execute(ILifetimeScope scope, IExecutionContext context, SandboxFabricCallTracker& sandboxFabricCallTracker) at Microsoft.Xrm.RemotePlugin.Client.SandboxFabricPlugin.<>c__DisplayClass5_1.<Execute>b__3() at Polly.Policy.<>c__DisplayClass150_01.<Execute>b__0(Context ctx, CancellationToken ct) at Polly.Policy.<>c__DisplayClass143_01.<ExecuteInternal>b__0(Context ctx, CancellationToken ct) at Polly.RetrySyntax.<>c__DisplayClass12_1.<WaitAndRetry>b__1(Context ctx, CancellationToken ct) at Polly.Retry.RetryEngine.Implementation[TResult](Func3 action, Context context, CancellationToken cancellationToken, IEnumerable1 shouldRetryExceptionPredicates, IEnumerable1 shouldRetryResultPredicates, Func1 policyStateFactory) at Polly.RetrySyntax.<>c__DisplayClass12_0.<WaitAndRetry>b__0(Action2 action, Context context, CancellationToken cancellationToken) at Polly.Policy.ExecuteInternal[TResult](Func3 action, Context context, CancellationToken cancellationToken) at Polly.Policy.Execute[TResult](Func3 action, Context context, CancellationToken cancellationToken) at Polly.Policy.Execute[TResult](Func1 action) at Microsoft.Xrm.RemotePlugin.Client.SandboxFabricPlugin.Execute(IServiceProvider serviceProvider) at Microsoft.Xrm.RemotePlugin.Client.ResilientSandboxPlugin.<>c__DisplayClass13_1.<Execute>b__0() at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) at Microsoft.Xrm.RemotePlugin.Client.ResilientSandboxPlugin.Execute(IServiceProvider serviceProvider) at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.RemotePluginExecute(IServiceProvider serviceProvider, ILifetimeScope lifetimeScope, IExecutionContext executionContext, ILogger logger) at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.Execute(IServiceProvider serviceProvider) at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext) -- End stack trace --

Exception type: Microsoft.Crm.Workflow.Services.InvalidCustomActivityExecutionException Message: 'pm_PreliminaryRiskAssessment' entity doesn't contain attribute with Name = 'pm_answeredcount ' and NameMapping = 'Platform'. MetadataCacheDetails: ProviderType=Dynamic, StandardCache=True, IsLoadedInStagedContext = False, Timestamp=2961192, MinActiveRowVersion=2961192, MetadataInstanceId=46321125, LastUpdated=2022-02-01 05:47:23.243 at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout) at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions) at Microsoft.Crm.Workflow.SynchronousRuntime.SynchronousWorkflowActivityHost.ExecuteWorkflowUsingInvoker(Activity workflow, ICommonWorkflowContext context) at Microsoft.Crm.Workflow.SynchronousRuntime.SynchronousWorkflowActivityHost.StartWorkflow(WorkflowActivationData activationData, ICommonWorkflowContext context) -- End stack trace --

, error code - -2147220891

pm_answeredcount is definitely the roll-up field name

Steps to reproduce the problem (screenshots are really usefull)

  • Create custom parent entity, pm_PreliminaryRiskAssessment with rollup field pm_answeredcount = COUNT(PRAresponses with statecode = "answered")
  • Create custom child entity, PRAresponse
  • Add workflow to PRAresponse entity that runs when statecode field changes
  • Add one step to workflow: msdyncrmWorkflowTools.CalculateRollupField, with the following properties image

CRM Version - online/onpremise - WorkflowTools version

Power Apps cloud. I used this fork of your tools, but I do not think that is the issue.

dnagirl avatar Feb 01 '22 18:02 dnagirl

Since I wasn't having any luck with the workflow, I decided to try replicating the function with javascript and a webAPI call. What I discovered is that I could generate the same error as above if I used the singular instead of plural entity name. ie: pm_preliminaryriskassessment instead of pm_preliminaryriskassessments.

When I used the workflow, the forms assistant generated the parent record URL. So I'm not sure why it generated a singular version. Any ideas?

dnagirl avatar Feb 07 '22 17:02 dnagirl