0
votes

I am using SharePoint 2013 SP1 and I am having a problem constructing the Email Activity To attribute.

Here's where I am at. I have a created a custom workflow and custom association and initiation form using SharePoint 2013.

My Assn. form is fine. I pass in the people Editor control (Active Directory group name ie. SharePointApprovers) value to my workflow just fine.

Now on my Init form I use the passed in value from people picker and display a list of users and email addresses from the people picker group. The list of users and email addresses are listed in a table with a check box to the left of each row. I am using JQuery, Knockout and MVC web service to retrieve the values from the group.

All is well.

Now my users pick who they want to send the email to. Let's say they pick two users! This means my variable is like this ([email protected];[email protected]).

When the user clicks the submit button, I have JSOM code which starts the workflow and sends in the 2 users email addresses as an argument to the workflow. Note: I tried sending my two emails as a array and failed but if I send it in as a string it works. The variable is called strUsers.

Since the argument is a string and Email Activity To attribute requires an array, I use the BuildCollection<String> Activity to convert my string strUsers to an array. I think this worked, as when I added a WriteToHistory Activity to my workflow my result in workflow history is as follows... "The value is [email protected];[email protected]".

I then configure the email Activity and set to To property to my BuildActivity variable (recipients). As this is an array.

When I deploy my Visual Studio 2013 solution, and attach my workflow to a publishing page, I am getting this error after I submit the Init form.

An unhandled exception occurred during the execution of workflow instance. System.ArgumentNullException.

Does anyone know of an example of how to set up the Email To collection value.

PS I have looked at this link but it is only passing in one variable. In my case I have a string of emails. I need to pass in an array to the Email To property.

1

1 Answers

0
votes

You need need to parse your strUsers string into a collection of strings before assigning that collection to the "To" field in your Email Activity.

You could roll your own solution to do this or take a look at this article.