Pre-populate Text Box in Display Form
Is it possible to pre-populate the texts boxes in a display form with data from a sql table?
I have a map that displays point data. When a point is clicked, a form opens with text boxes that allows a user to enter information, and submit that information into a sql table. I was wondering, if that data needs to be updated, is there a way to click on the point again and see the infomration that was previously entered already populated in the text boxes?
0
-
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 -
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...
Any ideas?0 -
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 -
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...
0 -
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 -
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... 
Here is my workflow, it's over 32,000 characters to I cant post it...
The Query Task...
The Design Form and Runtime Modifications...

I feel like I am missing a very simple piece of the puzzle...0 -
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 -
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 -
You should not use the SQL Non Query activity but the SQL Query activity. The first one will not return data. 0 -
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 -
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 -
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... 
My Select statement in the SQL Query activity is " Select * from (databasename) where Link = @id "
I have a parameter set...
And I created a 'sqlqueryresult' Results variable...
The DataTable to FeatureSet Activity comes next..pulling the 'sqlqueryresult' variable...
And finally the Alert...
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...
I really appreciate everyones input in this, workflows are not my thing! There has been quite a steep learning curve!0 -
sqlqueryresult.Rows.Item(0).Item("name").ToString()is what I think you are after. No need for DataTabletoFeatureSet.0 -

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 -
Before the alert, insert an Assign and set it to sqlqueryresult.tablename = "TableName". Serialization issues can be annoying... 0 -
sqlqueryresult.TableName 0 -
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 -
You will periodically run into serialization issues. They can be frustrating at times. Glad it worked! 0
Please sign in to leave a comment.
Comments
18 comments