public override void Execute() { EntityReference crmRecord = _crmContext.RecordCache[_alias]; var instance = BusinessProcessFlowHelper.GetProcessInstanceOfRecord(_crmContext, crmRecord); var path = BusinessProcessFlowHelper.GetActivePath(_crmContext, instance); int currentStage = -1; for (int i = 0; i < path.Length; i++) { if (path[i].Id == instance.GetAttributeValue <Guid>("processstageid")) { currentStage = i; } } if (currentStage == -1) { throw new TestExecutionException(Constants.ErrorCodes.CURRENT_BUSINESS_PROCESS_STAGE_NOT_FOUND); } if (currentStage + 1 >= path.Length) { throw new TestExecutionException(Constants.ErrorCodes.BUSINESS_PROCESS_STAGE_CANNOT_BE_LAST); } var processRecord = BusinessProcessFlowHelper.GetProcessRecord(_crmContext, crmRecord, instance.Id); processRecord["activestageid"] = path[currentStage + 1].ToEntityReference(); GlobalTestingContext.ConnectionManager.CurrentConnection.Update(processRecord); }
private ProcessStage GetCurrentStage(EntityReference crmRecord) { var instance = BusinessProcessFlowHelper.GetProcessInstanceOfRecord(_crmContext, crmRecord); return(new ProcessStage { ProcessId = instance.GetAttributeValue <EntityReference>("processid").Id, StageId = instance.GetAttributeValue <Guid>("processstageid") }); }
protected override void ExecuteBrowser() { var crmRecord = _crmContext.RecordCache[_alias]; var instance = BusinessProcessFlowHelper.GetProcessInstanceOfRecord(_crmContext, crmRecord); var path = BusinessProcessFlowHelper.GetActivePath(_crmContext, instance); var stageInfo = GetCurrentStage(instance, path); var browser = _seleniumContext.GetBrowser(); var record = browser.OpenRecord(new OpenFormOptions(crmRecord)); browser.App.App.BusinessProcessFlow.NextStage(stageInfo.StageName); record.Save(true); }
protected override void ExecuteApi() { var crmRecord = _crmContext.RecordCache[_alias]; var instance = BusinessProcessFlowHelper.GetProcessInstanceOfRecord(_crmContext, crmRecord); var path = BusinessProcessFlowHelper.GetActivePath(_crmContext, instance); var stageInfo = GetCurrentStage(instance, path); var processRecord = BusinessProcessFlowHelper.GetProcessRecord(instance); processRecord["activestageid"] = path[stageInfo.StageIndex + 1].ToEntityReference(); GlobalTestingContext.ConnectionManager.CurrentConnection.Update(processRecord); }
public override void Execute() { EntityReference crmRecord = _crmContext.RecordCache[_alias]; var instance = BusinessProcessFlowHelper.GetProcessInstanceOfRecord(_crmContext, crmRecord); var path = BusinessProcessFlowHelper.GetActivePath(_crmContext, instance); int currentStage = -1; int desiredStage = -1; for (int i = 0; i < path.Length && (currentStage == -1 || desiredStage == -1); i++) { if (_stageName.Equals(path[i].GetAttributeValue <string>("stagename"), StringComparison.OrdinalIgnoreCase)) { desiredStage = i; } if (path[i].Id == instance.GetAttributeValue <Guid>("processstageid")) { currentStage = i; } } if (currentStage == -1) { throw new TestExecutionException(Constants.ErrorCodes.CURRENT_BUSINESS_PROCESS_STAGE_NOT_FOUND); } if (desiredStage == -1) { throw new TestExecutionException(Constants.ErrorCodes.BUSINESS_PROCESS_STAGE_NOT_IN_ACTIVE_PATH, _stageName); } if (currentStage == desiredStage) { return; } var processRecord = BusinessProcessFlowHelper.GetProcessRecord(instance); if (desiredStage < currentStage) { processRecord["activestageid"] = path[desiredStage].ToEntityReference(); GlobalTestingContext.ConnectionManager.CurrentConnection.Update(processRecord); return; } while (desiredStage > currentStage) { processRecord["activestageid"] = path[currentStage + 1].ToEntityReference(); GlobalTestingContext.ConnectionManager.CurrentConnection.Update(processRecord); currentStage++; } }