How to get item from dictionary

by Elizabeth Szabo. » Wed Nov 12, 2014 3:05 pm

Hi,
I am using the Split String workflow action. The dictionary comes in a ["a","b","c"] format. How do I specify the path to the items?
Thanks!
Elizabeth Szabo.
 

by Roman Rylov » Wed Nov 12, 2014 3:07 pm

Hi Elizabeth,

Please read this article to understand how to work with split workflow action. See ‘How to use workflow actions’ section.

The key to get item from dictionary will look like this ({Variable:Index}), where Variable:Index is an index in the loop. The picture below shows how to enumerate through dictionary:

Image
User avatar
Roman Rylov
 
Posts: 335
Joined: Tue Nov 11, 2014 6:25 pm

by Elizabeth Szabo. » Wed Nov 12, 2014 3:07 pm

Thanks a lot!
Elizabeth Szabo.
 

by Roman Rylov » Wed Nov 12, 2014 3:08 pm

You are welcome!
User avatar
Roman Rylov
 
Posts: 335
Joined: Tue Nov 11, 2014 6:25 pm

by pawanashish » Wed Feb 18, 2015 3:10 pm

Hi Roman,
I am trying use split string from Plumsail and followed the steps that you mentioned in your post.
"Get Item from dictionary by Index" is not supported in SharePoint designer 2013. I get an error when I try to use this in my workflow as suggested in your post. Is there any work around that?
User avatar
pawanashish
 
Posts: 1
Joined: Wed Feb 18, 2015 2:53 pm

by Roman Rylov » Wed Feb 18, 2015 3:50 pm

Hello,

Please make a screenshot of the configured workflow action and a string that you are trying to split.
You can post it here or email us to support@plumsail.com
User avatar
Roman Rylov
 
Posts: 335
Joined: Tue Nov 11, 2014 6:25 pm

by geirmat » Tue May 05, 2015 9:44 pm

Did you find the answer to the last follow-up question on this post?
I think I might have hit upon something similar.
Using Action Pack to read people in a given access group into a Dictionary variable.
Using your guidelines for reading it out again
Ex of failing statement: Get [%Variable: index%] from Variable: Dictionary (result to Variable: person )

But execution fails with message:
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)
User avatar
geirmat
 
Posts: 31
Joined: Fri Dec 19, 2014 12:13 pm

by Roman Rylov » Wed May 06, 2015 2:46 pm

Hi Geir,

I would recommend you to use send email to see the whole object of your dictionary.
Also as I know if you're trying to get value from array you have to use brackets.
Example: Get ([%Variable: index%]) from Variable: Dictionary (result to Variable: person )
User avatar
Roman Rylov
 
Posts: 335
Joined: Tue Nov 11, 2014 6:25 pm

by geirmat » Fri May 08, 2015 3:26 pm

Thanks for responding, Roman.
Tried to include parenthesis. This gives a different error message:
System.InvalidCastException: The value '(0)' cannot be read as type 'String'. at Microsoft.Activities.GetDynamicValueProperty`1.CheckedRead(String propertyName, DynamicItem value) 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)

This is the key statements in my WF:
Get members of SharePoint group Variable: WF_GruppeMedl and save to Variable: Dictionary
Telle elementer i Variable: Dictionary (utdata til Variable: antall ) (= count )
Sett Variable: index til 0
LOOP antall TIMES
Get ([%Variable: index%]) fra Variable: Dictionary (utdata til Variable: person )
[Get variable. person=String, index=whole number)
Beregn Variable: index pluss 1 (utdata til Variable: kalk )
Sett Variable: index til Variable: kalk

Any obvious errors here?
This is executing in an 2013 List WF. Any issues here?
User avatar
geirmat
 
Posts: 31
Joined: Fri Dec 19, 2014 12:13 pm

by Roman Rylov » Mon May 11, 2015 8:51 am

Geir,

I can't say exactly where the error because I can't see the JSON value in your Dictionary.
If you want we can setup screen sharing session to fix the error, please write us to support@plumsail.com.
User avatar
Roman Rylov
 
Posts: 335
Joined: Tue Nov 11, 2014 6:25 pm

Next

Return to Workflow Actions Pack for Office 365

cron