I have a workflow that reassigns the owner based on a field called "QuoteWerks Prepared by". The "KED365" step is a custom workflow activity, and uses the code below: namespace KED365.Workflows { using System; using System.Activities; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Workflow; using Microsoft.Xrm.Sdk.Query; using System.Linq; public sealed class GetUserByFullName : WorkFlowActivityBase { [Input("User Full Name")] public InArgument UserFullName { get; set; } [Output("Prepared By")] [ReferenceTarget("systemuser")] public OutArgument PreparedBy { get; set; } [Output("IsSuccess")] public OutArgument IsSuccess { get; set; } [Output("Message")] public OutArgument Message { get; set; } protected override void Execute(CodeActivityContext activityContext, IWorkflowContext workflowContext, IOrganizationService CrmService, ITracingService trace) { try { string userName = UserFullName.Get(activityContext); if (string.IsNullOrWhiteSpace(userName)) { IsSuccess.Set(activityContext, false); Message.Set(activityContext, "User's Full Name is not provided"); return; } var QEsystemuser = new QueryExpression("systemuser"); QEsystemuser.ColumnSet.AddColumns("fullname"); QEsystemuser.Criteria.AddCondition("fullname", ConditionOperator.Equal, userName); var results = CrmService.RetrieveMultiple(QEsystemuser); if (results == null || !results.Entities.Any()) { IsSuccess.Set(activityContext, false); Message.Set(activityContext, "User with " + userName + " not found") ; return; } if (results.Entities.Count > 1) { IsSuccess.Set(activityContext, false); Message.Set(activityContext, "Multiple users found with same name : " + userName); return; } IsSuccess.Set(activityContext, true); PreparedBy.Set(activityContext, results.Entities.Single().ToEntityReference()); } catch (Exception ex) { IsSuccess.Set(activityContext, false); Message.Set(activityContext, "An error occurred trying to find user : " + ex.Message); } } } } -------------- The "Set properties" portion of this step sets the field to "QuoteWerks Sales Rep". Next, the record gets assigned to the user that was returned in the previous step. However, the workflow has suddenly stopped working. I receive the error below: The Owner was not provided. Plugin Trace: [Microsoft.Xrm.Sdk.Workflow: Microsoft.Xrm.Sdk.Workflow.Activities.AssignEntity] [Microsoft.Xrm.Sdk.Workflow (9.0.0.0): Microsoft.Xrm.Sdk.Workflow.Activities.AssignEntity] Error Message: Unhandled exception: Exception type: System.ArgumentException Message: The Owner was not provided -- End stack trace -- Exception type: Microsoft.Crm.CrmArgumentException Message: The Owner was not provided at Microsoft.Crm.Workflow.Services.AssignActivityService.Execute(ActivityContext executionContext, AssignEntity assignEntity) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) -- End stack trace -- The workflow worked fine until about a week ago. Any help fixing this would be greatly appreciated. Thank you!
↧