/// <summary>
        /// Prior to a new process step record creation, set the step parameter value to the template value
        /// defined on the associated step type if the value is currently blank.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="target"></param>
        /// <param name="createdProcessStepId"></param>
        private void addStepParameterTemplate(
            ICDSPluginExecutionContext executionContext,
            ccllc_processstep target,
            EntityReference createdProcessStepId)
        {
            if (target.ccllc_StepParameters == null && target.ccllc_ProcessStepTypeId != null)
            {
                var stepType = executionContext.OrganizationService
                               .GetRecord <ccllc_processsteptype>(target.ccllc_ProcessStepTypeId, cols => new { cols.Id, cols.ccllc_StepParameterTemplate });

                if (stepType.ccllc_StepParameterTemplate != null)
                {
                    target.ccllc_StepParameters = stepType.ccllc_StepParameterTemplate;
                }
            }
        }
        /// <summary>
        /// After creation of a new process step, link it up to the current last step in the process so that the
        /// new step becomes the last step in the process.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="target"></param>
        /// <param name="createdProcessStepId"></param>
        private void addAsLastProcessStep(
            ICDSPluginExecutionContext executionContext,
            ccllc_processstep target,
            EntityReference createdProcessStepId)
        {
            if (target.ccllc_TransactionProcessId != null)
            {
                var process = executionContext.OrganizationService
                              .GetRecord <ccllc_transactionprocess>(target.ccllc_TransactionProcessId, cols => new { cols.Id, cols.ccllc_InitialProcessStepId });

                // set the process initial step to this step if it is currently null.
                if (process.ccllc_InitialProcessStepId is null)
                {
                    process.ccllc_InitialProcessStepId = createdProcessStepId;
                    executionContext.OrganizationService.Update(process);
                }

                // find last step that has a blank subsequent step id that is not the newly created step.
                var lastStep = executionContext.OrganizationService.Query <ccllc_processstep>()
                               .Select(cols => new { cols.Id, cols.ccllc_SubsequentStepId })
                               .WhereAll(s => s
                                         .IsActive()
                                         .Attribute("ccllc_transactionprocessid").IsEqualTo(process.Id)
                                         .Attribute("ccllc_subsequentstepid").IsNull()
                                         .Attribute("ccllc_processstepid").Is(Microsoft.Xrm.Sdk.Query.ConditionOperator.NotEqual, createdProcessStepId.Id))
                               .OrderByDesc("createdon")
                               .FirstOrDefault();

                // Set the subsequent step on the last step to the newly created step.
                if (lastStep != null)
                {
                    lastStep.ccllc_SubsequentStepId = createdProcessStepId;
                    executionContext.OrganizationService.Update(lastStep);
                }
            }
        }