Skip to main content

How do I make my form output values update the selected feature's attributes?

Comments

4 comments

  • Zack Robison
    Where are you at here?  You just have a bunch of form outputs and need to update a feature service by the sound of it, so you'll need to prepare a featureset of a the correct format and use the update features activity in your workflow.  Presumably you have a featureset already with the appropriate feature(s) in it, so would only need to set the attributes and ship it to the server.  Building the form is most of the work in this case, so you're close!
    0
  • Justin Kraemer
    Thanks for your reply, Zack.

     

    You are correct that I have a featureset signFS. It is created from a ParallelForEach<EssentialsFeatureSet> activity that loops through the output of the GetSelectedFeatures activity. This is a highway signage inventory tool I am enhancing from one that currently uses the default Geocortex editing environment, over which I need more control.

     

    To show you the variety of data types I'm handling, I populate the form controls in RuntimeModifications using Assign activities such as

     

    form.Find(Of ComboBoxFormItem)("ComboBox12").SelectedValue = signFS.Features(0).Attributes("POST_SIZE").ToString

     

    and

     

    form.Find(Of TextBoxFormItem)("TextBox4").DefaultText = signFS.Features(0).Attributes("RETRO_REFL_TEXT").ToString

     

    and 

     

    form.Find(Of DatePickerFormItem)("DatePicker1").InitialDate = newInstalledDate

     

    So you are right that my challenge is how to "set the attributes and ship it to the server."

     

    At the bottom of my workflow I tried putting the UpdateFeatures activity, but when I clicked the Save button I got an Unhandled exception: 'Unable to complete operation.' in the DisplayForm activity . But then I thought better and moved UpdateFeatures to be within DisplayForm, and the error went away. Is this the proper place for it now?

     

    The parameters of UpdateFeatures, in case you can find fault in them are:

     

    In Arguments

     

    Credentials: <I've nothing here, but it's a secured map service, so should I, and by what example?>

     

    Feature Layer Url: signageLayer

     

    Features: signFS

     

    GDB Version: <I've nothing here, but it's a versioned sde feature class, so what should I?>

     

    Proxy Url: <I've nothing here because it's n/a>

     

    Token: theToken <same one I use throughout the workflow>

     

    Out Arguments

     

    Results: list 

     

    So now I need help in assigning the Output Arguments to the signFS attributes, because if I put signFS.Features(0).Attributes("POST_TYPE") in for the signPostType argument there, I get a disallowed implicit conversion from 'Object' to 'String' error. But if I tack on .ToString, i.e.

     

    signFS.Features(0).Attributes("POST_TYPE").ToString it reports "Invalid L-value expression". Is this even the place to be making such assignments? If so, how do I make them work? If the wrong place, then how else? 

     

    I look forward to your suggestions, and am grateful for you help.

     

     
    0
  • Zack Robison
    The update features activity does not belong in the runtime arguments for a form.  The runtime arguments sequence is logic that runs after the form has been built from its config (defined in the "design form" dialog) but before it is displayed in the user, so you can do things like run script logic to pre-set values for form items or add/remove items to the form dynamically.  I don't know why moving the "update" activity did anything for you at all because the error that you received before was related to the DisplayForm activity, so something is a bit amiss there.  The update activity belongs after your form at least.

     

    It took me a second to figure out what you're doing where you're getting this behavior but I think that I get it now... jsut to be sure: you're trying to place eg "signFS.Features(0).Attributes("POST_TYPE")" in the output argument value of a form item

     

    .

     

    So, I've see different variations of this issue pop up with some regularity and have been meaning to do a decent writeup that I can copy-paste-build upon in the future and here it is.  TLDR for your case: make string varibales to hold your form outputs and then assign the feature values in assignment activities later in the workflow.

     

    L-Value refers to the left-hand side of an expression (which is supposed to receive a value), so if you're calling a method over there like .tostring it'll break on you because you're now trying to set a value (not a variable) to something else, which doesn't make any sense.  Form output arguments basically have half of an expression built for you based upon the configuration (and runtime modification) of the form in the workflow.  In the case of a text box, that expression looks like "[your output variable] = [string value from user form input]" and you cannot change the right-hand side which means that whatever variable you place on the left hand needs to be, in this case, a string.

     

    Attribute values in a feature object are simple objects.  If you want the string output to go into an object variable, you need to convert the value from string to obj before asigning.  VB will automatically (or "implicitly") make this conversion for you in an expression UNLESS the scope of that expression has Option Strict or Option Explicit (https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba) turned on, which the forms do in order to prevent wayfaring developers from placing, say, a decimal value in an integer variable (bad move).

     

    TL;DR: Use a string variable for the output value and use an assignment activity to get the string variable into your featureset.
    0
  • Justin Kraemer
    Zack, thank you so much for your diligent efforts in helping me. I just wanted you to know my appreciation before too long, as I have not had time for this work yet today, and might not reach it again till next week. I will follow up as need be, if you don't mind.
    0

Please sign in to leave a comment.