Skip to main content

Pre-populate Text Box in Display Form

Comments

18 comments

  • Tom Neer
    Yes. Execute a query before the Display Form. You may have to do this in a Try/Catch as if there is no record you might throw an error. If it returns a value, use the Runtime Modifications to put in the value. 
    0
  • Permanently deleted user
    Hi Tom, thanks for the response, I"ve added a query task before the Display Form, and used an Assign activity in Runtime Modifications with the following values...

     

    To: form.Find(Of TextBoxFormItem)("TextBox1").DefaultText

     

    Value: featureset.Features(0).Attributes("name").ToString()

     

    But I am now getting this error...

     

    User-added image

     

    Any ideas?

     

     

     
    0
  • Tom Neer
    Lisa, instead of just an Assign, create an IF statement where featureset.Count() > 0, for true, set your True value to Assign (form.Find(Of TextBoxFormItem)("TextBox1").DefaultText

     

    Value: featureset.Features(0).Attributes("name").ToString()), leave your False value empty. 

     

    You have nothing in your featureset, that is why your index is out of range.
    0
  • Permanently deleted user
    Thank you so much Tom, that fixed the error, but I think I'm still missing something...When I run the workflow, the text box is still empty...

     

    User-added image

     

     
    0
  • Tom Neer
    Lisa, put in an Alert with featureset.Features(0).Attributes("name").ToString() in it. Does it return anything were you know there is data?
    0
  • Permanently deleted user
    Hi Tom, Would you suggest adding this Alert to the end of the Workflow? I'm very new to workflows so I dont know what best way to do this. When added to the end, I get this error again...

     

    User-added image

     

    Here is my workflow, it's over 32,000 characters to I cant post it...

     

    User-added image

     

    The Query Task...

     

    User-added image

     

    The Design Form and Runtime Modifications...

     

    User-added image

     

    User-added image

     

    I feel like I am missing a very simple piece of the puzzle...
    0
  • Tom Neer
    Put the Alert before the DisplayForm, you will need an IF statement just like in the Runtime Modification to test that there are features returned. But just to confirm, your FeatureSet has an attribute column "name" in it correct? From what I can see, your QueryTask is not returning any values. Should it? 

     

     
    0
  • Permanently deleted user
    Ok, I think that's the issue, the query task is querying the map service, whereas I need to be querying the sql table where the data is being stored from the SQL Non Query activity. That is where the 'name' attribute is coming from, from the sql table...
    0
  • Nico Burgerhart
    You should not use the SQL Non Query activity but the SQL Query activity. The first one will not return data.
    0
  • Permanently deleted user
    Hi Nico, I dont think I explained myself very well...as seen from the screen shot above, I am using a SQL Non Query Activity towards the end of the workflow to add data to a sql table. So what I think I need to do is add a SQL query activity at the beginning of the workflow to query that sql table in order to pre-populate the text box with the data that has already been entered...I'm just not sure how to go about doing that...
    0
  • Nico Burgerhart
    The SQL Query activity returns a DataTable. You can use the DataTable to FeatureSet activity to convert it to a featureset.

     

    You can use a statement like the one above myfeaturesetvariable.Features(0).Attributes("name").ToString() tot get the desired value from you featureset, in the runtime modifications section of your Display Form you should assign it to the DefaultText property of the texbox on your form.
    0
  • Permanently deleted user
    Alright guys, I'm banging my head against a wall here...I"ve broken the workflow down to make it simpler...We are querying the sql table, converting the datatable to a feature set, and then have an alert that should convert the "name" attribute to a string...

     

    User-added image

     

    My Select statement in the SQL Query activity is " Select * from (databasename) where Link = @id "

     

    I have a parameter set...

     

    User-added image

     

    And I created a 'sqlqueryresult' Results variable...

     

    The DataTable to FeatureSet Activity comes next..pulling the 'sqlqueryresult' variable...

     

    User-added image

     

    And finally the Alert...

     

    User-added image

     

    featureset.Features(0).Attributes("name").ToString()

     

    In the feature long description, I've configured the workflow to run from a hyperlink...

     

    <a href="command:RunWorkflowWithArguments?workflowId=BLLInspectionUpdate&id={id}">Update BLL Inspection</a></p>

     

    But I am getting this error when I try to run the workflow in the map...

     

    User-added image

     

    I really appreciate everyones input in this, workflows are not my thing! There has been quite a steep learning curve!

     

     
    0
  • Tom Neer
    sqlqueryresult.Rows.Item(0).Item("name").ToString() is what I think you are after. No need for DataTabletoFeatureSet.
    0
  • Permanently deleted user
    User-added image

     

    I have sqlqueryresult.Rows.Item(0).Item("name").ToString() in the ALert text box but am still getting the  above error "Cannot serialize the DataTable. DataTable name is not set.' What Data table is this error even referring to?
    0
  • Tom Neer
    Before the alert, insert an Assign and set it to sqlqueryresult.tablename = "TableName". Serialization issues can be annoying...
    0
  • Tom Neer
    sqlqueryresult.TableName
    0
  • Permanently deleted user
    YES! That was it! Thank you so much Tom! Like I said before, this learning curve has been steep! But baby steps are better then no steps!
    0
  • Tom Neer
    You will periodically run into serialization issues. They can be frustrating at times. Glad it worked!
    0

Please sign in to leave a comment.