Creating a List<DataItem> to pass to a ListBox
Hi,
I am fairly new to Workflow design, so this maybe a simple answer
I am creating a List<DataItem> to pass to a ListBox in a form and setting the Value of each DataItem to a Graphic object (obtained from a FeatureSet).
When I run the workflow simulator, I get the following error when I try to populate the list box
Error: Type 'ESRI.ArcGIS.Client.Graphic' with data contract name 'Graphic:http://schemas.datacontract.org/2004/07/ESRI.ArcGIS.Client' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Does anybody know what I need to do please
-
This post is old, but I'm in the same boat. New-ish to workflows and can't set a graphic to the value property of a DataItem. How did you workaround this? My plan is to create a dictionary to store the graphic in, and use the graphic's object id as the key, the entire graphic as the dictionary value. Then in the DataItem value, I'll just use the object id again... later the object id will be used to fetch the correct graphic from the Dictionary I'm about to create. Not sure why the data item can't store a graphic in the value object property, but it seems to be a serialization issue. 0 -
Hi Lance,
It sounds like you have a pretty good grasp of the issue here. If you read the help documentation for the Object To DataItem activity, you'll see this note:
"The ValueProperty of the Object can be of any type, but should be Data Contract Serializable if you intend to send the output DataItem to the client."
Using the list for a form involves sending the DataItem to the client, so you can basically read that as "the DataItem's value needs to be Data Contract Serializable". Here's some info on object types that meet that requirement (https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/types-supported-by-the-data-contract-serializer) .
Your plan to use the object id and look it back up from a dictionary sounds like a good one. If you're doing this, you can use the FeatureSet to DataItem List activity to make part of the process easy. A couple twists you could do to prevent having to build the dictionary:- After you have the objectid, use it for a new QueryTask to get the feature back again (Where Clause: OBJECTID = ...)
- After you have the objectid, loop through the original featurset using a ForEach (type graphic) activity on yourFeatureSet.Features. Inside the ForEach, use an If activity to check if the objectid (item.Attributes("OBJECTID").ToString()) matches the one the user selected from the form, and then perform whatever actions need to happen from there.
-Amanda0
Please sign in to leave a comment.
Comments
2 comments