Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Search for and edit single record in database

Avatar

Level 1

I am creating a few forms that access an Access database that will be used to enter data into the database.  I am able to open records from the database and scroll through records one at a time and have added features to be able to search for and display a single record.  The problem that I am having  is when I load a single record and then edit that record, I am unable to save any changes made to the record, in other words, the record doesn't update on the database.

I can add new records and edit records as long as I scroll to them using .next(), .last(), .first(), and .previous() commands; however, when I load a single record I can't figure out how to save changes to that record in the database.

1 Accepted Solution

Avatar

Correct answer by
Level 1

Here it is:

xfa.sourceSet.DataConnection.open();

xfa.sourceSet.DataConnection.first();

 

var oDataConnList = xfa.sourceSet.DataConnection.nodes

var nCount = oDataConnList.length;

 

for (var i = 0; i < nCount; i++){

    if (CurrentRecord.rawValue != SearchField.rawValue){

        xfa.sourceSet.DataConnection.next();

    }

}

This opens the data connection, makes sure it starts on the first record, counts the number of records and scrolls through each record until it finds the one the user searched for!

View solution in original post

2 Replies

Avatar

Level 1

Ok...so I think i can get it to work by doing something like:


xfa.sourceSet.DataConnection.open();

xfa.sourceSet.DataConnection.first();



var oRecordList = ???????????

var nCount = oRecordList.length;



for (var i = 0; i < nCount; i++){

    if (CurrentRecord.rawValue != SearchField.rawValue){

        xfa.sourceSet.DataConnection.next();

    }

}

where CurrentRecord is a text field that shows the index of the current record and SearchField is the field where a user enters the record that they are searching for.

I think I just need to figure out how to count the number of records in the database.  Any ideas?

Avatar

Correct answer by
Level 1

Here it is:

xfa.sourceSet.DataConnection.open();

xfa.sourceSet.DataConnection.first();

 

var oDataConnList = xfa.sourceSet.DataConnection.nodes

var nCount = oDataConnList.length;

 

for (var i = 0; i < nCount; i++){

    if (CurrentRecord.rawValue != SearchField.rawValue){

        xfa.sourceSet.DataConnection.next();

    }

}

This opens the data connection, makes sure it starts on the first record, counts the number of records and scrolls through each record until it finds the one the user searched for!