cancel
Showing results for 
Search instead for 
Did you mean: 

"Assign to User" equivalent in Unity Script

Josh_Belmonte
Champ on-the-rise
Champ on-the-rise

Is there an equivalent in an iWorkflow script of the workflow action "Assign to user" for rule-based load balanced workflow queues?

1 ACCEPTED ANSWER

Alex_French
Elite Collaborator
Elite Collaborator

I don't think so.  Our approach for that need is to have the script set a Property, and have Workflow Assign To based on the Property.

View answer in original post

3 REPLIES 3

Alex_French
Elite Collaborator
Elite Collaborator

I don't think so.  Our approach for that need is to have the script set a Property, and have Workflow Assign To based on the Property.

That's a good idea.. do you have any sample code for assigning value to a property? Or can you point me to the section in the SDK that goes over this.

About as easy as it can get, off the WorkfowEventArgs object:


args.PropertyBag.Set("propName", "a value");

args.SessionPropertyBag.Set("propName2", "another value");


Reading a property set by Workflow is a teeny bit more work, using a standard C# "TryGetValue()" on args.PropertyBag. I like to wrap it up in a little extension method, something like this:


public static class MyExtensionMethods
{


public static string GetString(this Hyland.Unity.Workflow.PropertyBag thisPropertyBag, string propertyName, string defaultValue = "")
{


string value;
return thisPropertyBag.TryGetValue(propertyName, out value) ? value : defaultValue;

}

}


I like to keep many Unity scripts working as much as possible as "pure functions"- they take an input via properties and return an output via a property. Workflow sets inputs, and uses the outputs. That is often helpful for putting things that need to be in a script, or are clearest to implement in a script, while keeping as much business logic as possible in Workflow. It also can be helpful for making a script more generic and re-usable without making it itself more complicated.

Of course, that approach doesn't always make sense (there are other times when I'll argue that once a script is involved, it is cleanest to have it do as much as possible in one place), and trying to do it blindly or everywhere will just add complexity and confusion.