I need to create a dictionary array for the list items fetched using for each list item as shown below. I am getting the list item index and then passing it with dictionary to create an array but when I run it throws me error at assign activity - ‘Object reference not set to an instance of object’. Thanks to @Yoichi for below post, I am trying to assign dictionary values like mentioned in below post:
Note that a dictionary is not an array, it is very different from an array.
Go to your variables pane and in the default for your dictionary variable put:
New Dictionary(Of String, Object)
I’m just assuming String, Object because that’s what is typically used. You may have other requirements, a dictionary can be many things ie String,String, String,Datatable, or even a dictionary of dictionaries (Of String, Dictionary(Of String,Object)
However, now the problem is any number of dictionaries can come in this array based on the filter value. So, I can’t initialize this array that many times in advance.
Is there a way I can assign all dictionaries at once to this array?
Or may be keep joining dictionaries to the array?
Code works fine till the level I have initialized array in variable panel but based on the filter, no of items can change, so it needs to be initialized at runtime or some other way…
Did you create your list as Array(of Dictionary,Object)? Arrays are static, you can’t change the number of elements after they’re created. That’s why I use IEnumerable(of …) and then initialize it as “New List(of…)” - that way you can use the .concat({newelement}) expression to add items to it.
No, I am using Array of dictionary, that explains why it didn’t work for me.
Thing is I have a process which uses get list items - Sharepoint package output of which was dictionary array, but that is no longer working, hence switching to get list items -Office 365 api which gives output as datatable.
Intention is to be able to get the data in same format(dictionary array, as it was before) so we don’t have to change the further underlying code.
You don’t have to stick to dictionary array. They’re all basically interchangeable. Try it the way I showed you with the variable datatype as IEnumerable(of dictionary(of string,object)) and use the .concat operator to add items.
If you use IEnumerable instead of Array, and initialize it as New List(Of datatype) then you don’t have to initialize it with a specific number of elements. You can just add elements to it with .concat