Expand my Community achievements bar.

Attach a database script to a button

Avatar

Former Community Member
Hi,



I'm trying to implement database functionality to my form. there I use the JavaScript scripts.

xfa.sourceSet.DataConn.first ()...

everything works fine, except the ".addNew()" script.

Is there any possibility to find out what went wrong?

or why the script does not work?



any hints how to perform more complex data manipulation?



regards

Johannes
14 Replies

Avatar

Former Community Member
Which database are you using? I have used the addNew() with Access without issue.

Avatar

Former Community Member
Paul, the form I'm building is a replicating form and I will eventually need some database connectiviity, I presume through a button that generates a javscript script that will submit these new records to an Access DB.



Can you show me what you have used in the past with the addnew() script? This may be my answer to what I'm looking for.



Thank you in advanced.

Avatar

Former Community Member
In Access you have to create a new Record first then when that record is created you will have to modify add.



If you post your email address I will send you my sample forms.....without dbs



Paul

Avatar

Former Community Member
Thanks Paul for the quick reply. I appreciate your assistance. email is bgubanich@celeren.com.



Thank you again, I will get back to you with my outcome.



Take care

Avatar

Former Community Member
I am having the same issue with addNew() using MSSQL 2005 connection.

all other dbConnection methods work fine. any ideas?



I did try the addNew() first followed by the update() method but did not make a difference.



Could it be that I am using the trial version?



Thanks,

Marc

Avatar

Former Community Member
Does the user have rights to add a new record?

Avatar

Former Community Member
Paul,



The user hass full rights (dbo). I am using the same login through my application and that works fine.



Thanks,

Marc

Avatar

Former Community Member
If you are using Acrobat you can hit the Ctrl-J key after the script has run and if there is a Javascript error then it will show up there. Also if the DB returned an error it should show up there as well.

Avatar

Former Community Member
Paul,



Here is the erorr I am receiving after the I click on the update button:



GeneralError: Operation failed.

XFAObject.update:1:XFA:topmostSubform[0]:Page1[0]:Button4[0]:click

updateRecord operation failed. Multiple-step operation generated errors. Check each status value.[applicant_tracking_id_PK:11]



Note: the applicant_tracking_id_PK is an identity column.

Avatar

Former Community Member
Is it possible that the data type that you are adding to that column does not match what is defined in the DB?

Avatar

Former Community Member
The applicant_tracking_id_PK column is a numeric(18,0) with identity set to "Yes". This is the index key to the table and MSSQL server auto assigns the value to this column not the user.





Thanks,

Marc

Avatar

Former Community Member
Maybe the database does not allow an empty record when you do the addNew().

Avatar

Former Community Member
The only way I get this to work is to remove the primary key from the table and to allow null values in the columns. There has to be a way to insert a record into a table with a primary key and the identity option is set to "Yes".



I appreciate you looking into this.



Best Personal Regards,

Marc