Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Set output parameter value in catch block of a custom workflow activity

$
0
0

Hi All,

I am trying to send a notification when a custom workflow activity is postponed till 9999. 

For this I have custom workflow with output Parameter which i am defaulting to true. In catch block i am trying to set this value to false but it's not happening.

I am using this output parameter to check if value of this paramter is false in workflow then i will send a notification that workflow has failed.

Please refer my code and lt me know how to achieve this as we cannot pass execution context in Exception.

[Output("Workflow Status")]
        [DefaultAttribute("true")]
        public OutArgument<bool> Workflow_Status { get; set; }
		
		try
            {
                IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

                // Load Case-Type Guid List From Parameters
                string[] crmCaseTypeId = this.LoadCaseTypeFromInputParameters(executionContext, service);

                if (crmCaseTypeId != null && crmCaseTypeId.Length > 0)
                {
                    // Get all active case with specific case type
                    this.UpdateCaseAge(service, crmCaseTypeId);

                    // Send case summary email
                    this.SendCaseNotificationEmail(service, crmCaseTypeId, executionContext);
                }

            }
            catch (Exception ex)
            {   // CR 10-11-2016
                Workflow_Status.Set(executionContext, false);
                // CR 10-11-2016
                throw new Exception(ex.Message + Environment.NewLine + ex.StackTrace);
            }

Regards,

Saad


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>