0
votes

I have a workflow that reassigns the owner based on a field called "QuoteWerks Prepared by".

I cannot seem to post a screenshot in StackOverflow, so please see screenshot in my post in another forum here: https://community.dynamics.com/crm/f/117/p/358168/941269#941269

The "KED365" step is a custom workflow activity, and uses the code below.

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 --

I see the error says "The owner was not provided", but I cannot figure out why it has suddenly stopped working or how to fix it. The workflow worked fine until about a week ago. Any help fixing this would be greatly appreciated.

Thank you!

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<string> UserFullName { get; set; }
[Output("Prepared By")]
[ReferenceTarget("systemuser")]
public OutArgument<EntityReference> PreparedBy { get; set; }

[Output("IsSuccess")]
public OutArgument<bool> IsSuccess { get; set; }
[Output("Message")]
public OutArgument<string> 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;
}

(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);
}
}
}
}

--------------
1
observations, error says owner was not provided I.e does your customer workflow successfully find user based on full name or does it found more than one because assignment of record needs owner to be set and Crm cannot set it. Next thing can u give a specific fullname that you are sure is a user in system and also unique so that u can verify. can u profile workflow so that u can debug and check where exactly it is failing. can u create new temporary workflow(not custom) and assign the record to a hardcoded user. user u are assigning record to does it have security roles for the record/ entityAnkUser

1 Answers