I'm a bit puzzled why the Id field is there. I didn't select it, and the guide I followed didn't have this field either :/?
It generates this form for me:
Error
But when I try to submit form data I get the following error. Which isn't nice.
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Why is the Id field added to my form when I didn't select it?
How is the form linked to my table? When I create a new form I cannot set a data source for it, and I cannot find any config on the generated form that points to my data source.
How are form fields linked to a table column? Is it via the "display name"?
Why do I get the above Null Reference when trying to submit my form?
Can I ask a few more details please - what version of SQL is this?
It's running on the SQL server bundled with Visual Studio 2015 so that would be SQL Server v12.0.2000 (I think that is referred to as SQL Sever 2016 but not sure)
If you aren't scared to get your hands dirty with some code, I just released a couple of addons form forms that allow you to connect third party db data and submit to those, via workflow or via datasource (but you'll have to map your db table to a poco) http://www.nibble.be/?p=505
I'm not sure what I did. But now Umbraco Forms caught up with some of my changes. And I think I figured out what the problem is.
First off, the Id column is set to IDENTITY so the default form that is generated includes the Id. This is a problem. So I removed it from the form but the datasource.mappings section still has a reference to the Id column and that was causing issues.
So in my desperation I added the Id field to the form again, via the frontend, but this new Id field didn't have a link to data source column. In other words the dataSourceFieldKey was null. And that was causing the null reference in the OP.
So in conclusion the data source aspect of Umbraco Forms needs a bit of work. Perhaps it's already on your roadmap?
I'm still interested in knowing why changing the json file only sometimes updates the frontend.
Almost forgot :)
The fix was to remove the field containing the Id in pages.fieldSets.containers.fields and the map containing the Id column in datasource.mappings inside the UmbracoForms\Data\forms\ab45333b-1cf1-4526-b2c8-474dae089608.json file. And then
save the file
close Visual Studio
open it again
relaunch the site
open the umbraco forms admin section and reload a few times
Hello Eskild,
Great to see you being active in finding a solution.
These JSON files are not intended to be edited manually. These files are cached as .NET objects for use and hence you are seeing a delay. Restarting the site/app pool will obviously clear the cache here for this.
Yes it does seem that you have found a bug and I recommend posting details of this on the issue tracker so it can be put into the backlog and considered for next sprint grooming meeting.
Null Reference when submitting Umbraco Forms to custom data source
I'm trying to make Umbraco Forms (Umbraco v7.5.3) save to my own data source. I followed this guide: http://www.nibble.be/?p=84
And it appears to work-ish. I can connect and generate a form based on the table. Which is nice.
My setup
I add a new forms data source with the connection string:
My table looks like this:
The Id (PK) property is configured as Identity
I choose some fields I want to use in the form:
I choose which data types it should use:
I'm a bit puzzled why the
Id
field is there. I didn't select it, and the guide I followed didn't have this field either :/?It generates this form for me:
Error
But when I try to submit form data I get the following error. Which isn't nice.
Questions
Id
field added to my form when I didn't select it?Null Reference
when trying to submit my form?Hello Eskild,
Thanks for the detailed notes for this.
I will need to spend some time trying to replicate the problem and get back to you.
Can I ask a few more details please - what version of SQL is this?
Thanks,
Warren
It's running on the SQL server bundled with Visual Studio 2015 so that would be SQL Server v12.0.2000 (I think that is referred to as SQL Sever 2016 but not sure)
Comment author was deleted
Think it might be due to the fact that the connstring isn't OleDB Compatible
What part isn't OleDB compatible?
It connects to the database and can do schema lookups - so it's not totally broken :)
Comment author was deleted
If you aren't scared to get your hands dirty with some code, I just released a couple of addons form forms that allow you to connect third party db data and submit to those, via workflow or via datasource (but you'll have to map your db table to a poco) http://www.nibble.be/?p=505
This seems like the exact thing I'm looking for :) I'll give it a try
Hmmm, after installing "UI-O-MATIC LOVES UMBRACO FORMS" umbraco have become extremely slow.
Sadly I cannot use the addon as the data source needs to be maintained without having to code, so having to create a POCO is a deal breaker :(
Comment author was deleted
Ok understand that :) Then I think it's time for @Warren to do some debugging
Comment author was deleted
the backoffice or the frontend?
Installing Umbraco Forms via the Umbraco Frontend also, not just via Nuget fixed it.
Comment author was deleted
strange but glad it's fixed
So I've been poking around a bit and found these
The latter holdes info about which fields the form have and how they map to the data source. Great! But changing the json file does nothing :(
So my question is. How do I make Umbraco aware of my changes in the json file, or where do I edit the source the json file is generated from?
I'm not sure what I did. But now Umbraco Forms caught up with some of my changes. And I think I figured out what the problem is.
First off, the Id column is set to IDENTITY so the default form that is generated includes the Id. This is a problem. So I removed it from the form but the
datasource.mappings
section still has a reference to the Id column and that was causing issues. So in my desperation I added the Id field to the form again, via the frontend, but this new Id field didn't have a link to data source column. In other words thedataSourceFieldKey
wasnull
. And that was causing the null reference in the OP.So in conclusion the data source aspect of Umbraco Forms needs a bit of work. Perhaps it's already on your roadmap?
I'm still interested in knowing why changing the json file only sometimes updates the frontend.
Almost forgot :) The fix was to remove the
field
containing the Id inpages.fieldSets.containers.fields
and themap
containing the Id column indatasource.mappings
inside the UmbracoForms\Data\forms\ab45333b-1cf1-4526-b2c8-474dae089608.json file. And thenHello Eskild,
Great to see you being active in finding a solution.
These JSON files are not intended to be edited manually. These files are cached as .NET objects for use and hence you are seeing a delay. Restarting the site/app pool will obviously clear the cache here for this.
Yes it does seem that you have found a bug and I recommend posting details of this on the issue tracker so it can be put into the backlog and considered for next sprint grooming meeting.
http://issues.umbraco.org/issues/CON
Many Thanks.
Warren
is working on a reply...