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 :

Workflow ‘InvalidCastException’ or ‘Workflow contains an invalid custom activity’ Error | Oracle Series

Yagasoft Profile Picture Yagasoft 238

Issue

Sometimes on importing a solution in CRM v8.x, it might fail with the error: ‘Workflow contains an invalid custom activity’. In an effort to try to conquer the ambiguity, I tried to create said Workflow manually on the target environment.

Adding each step went well until I noticed that one of those steps, namely a certain Custom Step, caused the error: ‘InvalidCastException’. The error might look something like this:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.InvalidCastException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #B947377DDetail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ActivityId>b1989af8-b3e2-4e77-b8bc-6630796f0063</ActivityId>
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>System.InvalidCastException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #B947377D</Message>
  <Timestamp>2020-06-25T09:13:07.4937933Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault i:nil="true" />
  <OriginalException i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>

Investigation

Upon further investigation, it turned out that the Custom Step accepts an Option-set argument with a default value set.

The following code highlights the issue:

        [Input("Option-set Field")]
        [AttributeTarget("new_test", "new_optionsetfieldcode")]
        [Default("1")]
        public InArgument<OptionSetValue> OptionSetFieldArg { get; set; }

On line 3, the Default Attribute caused an error because of the String value. It seems that CRM tries to cast it to an Integer but fails.

Solution

Removing said Attribute fixed the issue.

Resources

Community Thread

More

The post Workflow ‘InvalidCastException’ or ‘Workflow contains an invalid custom activity’ Error | Oracle Series appeared first on Yagasoft Blog.

Comments

*This post is locked for comments