How do I build a String[] from a dynamic value?
I have an Initiation form that I collect email information and pass to my workflow as an Argument of type string
function StartWorkflow() {
var wfParams = new Object();
//build array of objects
var emailUsers = new Array();
//cycle through viewmodel emails
for (var i = 0; i < viewModel.SelectedEmails().length; i++)
{
var a = new Object();
a["emails"] = viewModel.SelectedEmails()[i];
emailUsers.push(a);
}
wfParams['strSelectedEmailsHMgr'] = JSON.stringify(emailUsers);
**This all works fine!**
IN my SharePoint 2013 workflow, I then create a dynamic Value variable called dvJSON. Next, I add a ParseDynamicValue activity and set my variable dvJSON to my incoming argument wfParams['strSelectedEmailsHMgr'].
Next, I add a WirteToHistory activity. here's the result: The value of dvJSON is [{"emails":"[email protected]"},{"emails":"[email protected]"},{"emails":"[email protected]"},{"emails":"[email protected]"},{"emails":"[email protected]"}]
Next, I add GetDynamicValueProperty and set the ProperyName to "emails" source dvJSONa result reciepients (string array variable).
I then Deploy my solution. When I start my workflow, I am presented with my custom initiation form. I select my email users and click Start button to start the workflow.
The GetDynamicValueProperty fails.
Here is the error below.
RequestorId: d8a1f1c4-4b83-da9c-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.InvalidOperationException: Looking up a value using a key is not supported on an instance of 'Microsoft.Activities.Dynamic.DynamicJsonArray'. at Microsoft.Activities.Dynamic.DynamicItem.TryGetValue(String key, DynamicItem& value) at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ObjectPathSegment.Get(DynamicItem obj) at Microsoft.Activities.GetDynamicValueProperty`1.Execute(CodeActivityContext context) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Thanks Tom