How to grab an attribute value from a FeatureSet
I have a featureset as a result of a QueryTask. All I want to do is get the string value of a few attributes for my workflow. My latest try is this:
fsMyRoads.Features.Item[0].Attributes("OwnerEntity").ToString()
The red exclamation mark says, "End of expression detected." Any ideas, community?
0
-
try:
fsMyRoads.Features(0).Attributes("OwnerEntity").ToString0 -
In my workflow, I know that fsMyRoads has a value, and I'm in an Else statement where I have already checked if Features.Count = 0 (which means that Features.Count isn't 0). But I get this error message when doing a Write activity with the code you suggested:
Object reference not set to an instance of an object.
I believe it's because the value of the field is null. What would I do to grab just an empty string if the field's value is null?
** Actually, as a more general question, where should I go to research this stuff myself? I haven't found the Geocortex Workflow Help to be much help with VB syntax, nor the ArcGIS Server REST API help. Where can I go to answer my own questions on expression syntax?0 -
You are on the right path Roger. Basically the error is being thrown because you are trying to convert a null value to a string. What I do to bypass this is use the following:
String.Format("{0}",fsMyRoads.Features(0).Attributes("OwnerEntity"))
What this is doing is putting the value of OwnerEntity into a string at the wildcard location {0}. So if it is null, it still creates a string, but it is empty. The benefit of this is that you don't need to check to see if the value of the attribute is null first and it won't error out when you want an attribute written as a string when the value is null. (https://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx#Starting)
For me, google is my friend looking up questions in workflow. The tough part is knowing the question to ask.0 -
I'm a programmer and all, I just don't have a lot of experience with Microsoft languages outside the old VBA for ArcMap. What I just need to know is the language being used by Geocortex Workflow (I believe it's VB .NET or VBScript or something) and then I can find the official Microsoft docs and find the right stuff there. The document that gave me the previous syntax was C# help which is why I had parentheses after ToString. 0 -
VB.NET
I would start here
Visual Basic Language Reference https://msdn.microsoft.com/en-us/library/sh9ywfdk.aspx
Dot Net Perls VB.NET https://www.dotnetperls.com/vb0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
5 kommentarer