My sharepoint list has a lookup field which allows for multiple selections. This field/column comes into the datatable in studio as a system.object. See Sharepoint list values and my Studio Data table (note i am only getting 2 fields “title” and “resources to be assigned”).
I am trying to figure out how to turn the system.object into a combined string, with the values shown in sharepoint combined as 1 string variable separated by a ;.
To concatenate the first few columns into a string just iterate through the values in your array row and concatenate them using the + symbol.
For the one labeled as system.object[ ], there are many things to try. First thing to notice is that it is an Array of generic O objects, so the values you want are definitely members of your array within your row array. Meaning, if the index of that column is 3, you would have to access the object value by doing something like MyRowArray[3][0], to get the first object stored in your object array. I’m assuming you could do the same and get its value with a simple .ToString().
So try, MyRowArray[][0].ToString
My second go-to would be to use the locals pane and the Immediate panel during debugging to determine the structure of this object. If it is obvious and I can see that the object has some clear properties to access I would use those by name. If not, I would try to see what that object can be casted as by studying its structure.
Then you can append this value the same way as the other strings.
I will give your suggestions a try! The screenshot showing the system.object is from the locals/immediate panel of the script execution paused after getting the list. This is the data table I captured.
So I’m order to try your suggestion, I would need to use a for each data table row activity, inside of that I would have an assign activity with MyRowArray[3][0] and assigning that to a string variable? Am I following you correctly?
As per screenshot it is a system.object[] which is an object array…
So use a for loop with ‘dt.Rows(0)(1) this gets the first roe second item which is to be used in in argument of for loop
Inside loop use currentitem.ToString in log message and check what is the value…
Also generally for look up firlds you would get the id may be you need to perform a separate call to get the value of id on a different list.check the same
Ok I have tried to piece together what you have explained but I am not sure I totally get it. Please see the attached screenshots of what I put together and if you could, point out where I went wrong lol.
I do the Get List Items and output the DT as LIstItemsDT.
Then i have a for each row loop, looping through that LIstItemsDT.
I then do an assign, on the column that is the system.object, and save that to a system.object variable.
I then converted that system.object variable to a IEnumerable using ctype (because the for each loop said it couldnt loop through the system.object variable.
And then i had a log message write the currentitem.tostring. but the output in the logs came as System.Collections.Generic.Dictionary`2[System.String,System.Object].
Any ideas on what i need to do to get the values out of System.Collections.Generic.Dictionary`2[System.String,System.Object]?
I looked inside the local panel while doing the for each row in datable and i see this(see below) for the current row. so i can see my values that i want to extract, but i am not sure how. I know you mentioned the MyRowArray[3][0] but i am not sure how to use that within the assign?
Here is my current row value (please note i removed the emails and replaced them with emailvalue1 and emailvalue2. Those are the values i want to extract and concatenate into a string separated by ; )
DataRow { HasErrors=false, ItemArray=object[9] { “1”, “sdfgdgfsdfg”, “2738”, “2738”, “Requested”, “other column value”, object[2] { Dictionary<string, object>(2) { { “LookupId”, 1 }, { “LookupValue”, “emailvalue1” } }, Dictionary<string, object>(2) { { “LookupId”, 368 }, { “LookupValue”, “emailvalue2” } } }, “Requested”, object[2] { Dictionary<string, object>(2) { { “LookupId”, 1 }, { “LookupValue”, “1” } }, Dictionary<string, object>(2) { { “LookupId”, 368 }, { “LookupValue”, “368” } } } }, RowError=“”, RowState=Added, Table=[DataTable] }
Ok I have successfully figured out how to extract those values!!
I don’t know if i was able to do it the way you suggested, but i realized that my studio’s System.Activities package was an older version where i could not specify the type argument for the for each loop. I upgraded it, and changed it to system.collection.generic.dictionary of string object. from there i was able to use the currentitem.item(“LookupValue”).ToString to get the values i need.
I really appreciate your help with this and being so patient with me!