locked
Workflow halts on waiting and shows validation errors on parameters RRS feed

  • Question

  • Hi,

    I've created 2 workflows but they won't pass the validation of crm and halts on waiting.

    Using CRM 2011 RU14 On Premise.

    The error message is :

    Unhandled Exception: System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
    'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error:   Compiler error(s) encountered processing expression "DirectCast(CustomActivityStep1_5_converted, Microsoft.Xrm.Sdk.OptionSetValue)".Invalid L-value expression.:Reference expressions cannot end with Conversion. The provided expression's type must exactly match the type T of VisualBasicReference<T> or LambdaReference<T>.
    'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error:   Compiler error(s) encountered processing expression "DirectCast(CustomActivityStep1_6_converted, System.Boolean)".Invalid L-value expression.:Reference expressions cannot end with Conversion. The provided expression's type must exactly match the type T of VisualBasicReference<T> or LambdaReference<T>.
       at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
       at System.Activities.WorkflowApplication.EnsureInitialized()
       at System.Activities.WorkflowApplication.Enqueue(InstanceOperation operation, Boolean push)
       at System.Activities.WorkflowApplication.WaitForTurn(InstanceOperation operation, TimeSpan timeout)
       at System.Activities.WorkflowApplication.InternalRun(TimeSpan timeout, Boolean isUserRun)
       at Microsoft.Crm.Workflow.ActivityHost.StartWorkflowExecution(Activity workflow, ICommonWorkflowContext context)
       at Microsoft.Crm.Workflow.ActivityHostBase.StartWorkflow(ICommonWorkflowContext context, Activity preLoadedActivity)

    My parameters are coded as followed. I can select the optionset value in crm for this workflow and the boolean is translated to a checkbox.

    Optionsetvalues are 1,2 and 3 so that shouldn't be a problem either.

    [Input("Output Format")]
            [AttributeTarget("pwb_documentgenerator", "pwb_outputformat")]
            [Default("1")]
            public InOutArgument<OptionSetValue> DocumentOutFormat { get; set; }

            [Input("Send Email")]
            [Default("False")]
            public InOutArgument<bool> SendEmail { get; set; }

    Been trying several things but can't get it to work.

    Any suggestions?

    Regards,

    Sven Peeters

    Wednesday, August 28, 2013 3:09 PM

All replies

  • The code looks fine. Can you post a screenshot of the values you're passing in? And also if you could post the entire class I can try running it.

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Thursday, August 29, 2013 7:19 AM
  • Hi Paul,

    The code

    public class CreateNoteOnEntity : CodeActivity
        {

    [RequiredArgument]
            [Input("Document Template")]
            [ReferenceTarget("pwb_documenttemplate")]
            public InArgument<EntityReference> DocumentTemplateReference { get; set; }

            [Input("Document Type")]
            [ReferenceTarget("pwb_documenttype")]
            public InArgument<EntityReference> DocumentTypeReference { get; set; }

            [Input("Output Format")]
            [AttributeTarget("pwb_documentgenerator", "pwb_outputformat")]
            [Default("1")]
            public InOutArgument<OptionSetValue> DocumentOutFormat { get; set; }

            [Input("Use Activity's Regarding Object")]
            [Default("False")]
            public InOutArgument<bool> UseActivityRegarding { get; set; }

            protected override void Execute(CodeActivityContext executionContext)
            {
                XRMConnect _XRMConnect = new XRMConnect(executionContext);

                try
                {
                    //Get Input Parameters
                    EntityReference _docTemplateRef = executionContext.GetValue(this.DocumentTemplateReference);
                    EntityReference _docTypeRef = executionContext.GetValue(this.DocumentTypeReference);
                    OptionSetValue _docOutputFormatRef = executionContext.GetValue(this.DocumentOutFormat);
                    Boolean _useActivityRegarding = executionContext.GetValue(this.UseActivityRegarding);

                    //Get Primary Entity Reference
                    EntityReference _regardingObject = new EntityReference(_XRMConnect.workflowContext.PrimaryEntityName, _XRMConnect.workflowContext.PrimaryEntityId);

    ...

    }

    }

    }

    Thursday, August 29, 2013 1:37 PM