These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Populate Fields from a database

gblodgett
Registered: Aug 21 2007
Posts: 4

After reading more I have now done this below and it is still not working nor is my drop down working anymore. I am trying to have the user choose data from a drop down and then that drop down populates the rest of the fields on the form from the oracle db - Please Help:
----- form1.Screen.ZZ_EEID::initialize: - (JavaScript, client) -------------------------------------
 
var sDataConnectionName = "AbraData";
var sColHiddenValue = "ZZ_EEID";
 
var nIndex = 0;
while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oDB = xfa.sourceSet.nodes.item(nIndex);
oDB.open();
oDB.first();
 
var nDBIndex = 0;
while(oDB.nodes.item(nDBIndex).className != "command")
{
nDBIndex++;
}
 
var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");
var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");
 
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF","bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF","eofAction");
 
this.clearItems();
 
nIndex = 0;
while(xfa.record.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oRecord = xfa.record.nodes.item(nIndex);
 
var oValueNode = null;
var oTextNode = null;
 
for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++) { if(oRecord.nodes.item(nColIndex).name == sColHiddenValue) { oValueNode = oRecord.nodes.item(nColIndex); } }
 
while(!oDB.isEOF())
{
this.addItem(oValueNode.value);
oDB.next();
}
 
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup,"bofAction");
oDB.,nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup,"eofAction");
 
oDB.close();
 
----- form1.Screen.Button1::click: - (FormCalc, client) --------------------------------------------
 
if (HasValue(ZZ_EEID)) then
$sourceSet.AbraData.#command.query.commandType = "text"
var sqlString = Concat("Select ZZ_EEID, ZZ_RISK_RT, ZZ_MATRIX_RT, ZZ_CONTRIB_RT, ZZ_OVERALL_RT From PS_ZZ_RATING Where ZZ_EEID = '",
Ltrim(Rtrim(ZZ_EEID.rawValue)),"'")
$sourceSet.AbraData.#command.query.select.sqlString
$sourceSet.AbraData.open()
endif

My Product Information:
LiveCycle Designer, Windows
pdftrainer
Expert
Registered: Dec 14 2005
Posts: 180
I would suggest posting this question over at the LiveCycle Designer forum.

[url=http://www.adobeforums.com/cgi-bin/webx/.3bb7d189/]http://www.adobeforums.com/cgi-bin/webx/.3bb7d189/[/url]

A certified expert on Adobe Acrobat, Carl Young is an Adobe Acrobat and LiveCycle Designer trainer and consultant based in Phoenix. He is the producer of the [link=http://www.pdfconference.com/]PDF Conference[/link].

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You seem to have gotten past the initial stage of finding some XFA DB code and modifying it for your own purpose. Congratulations!! It looks like you copied code from the Data-DropDown in the Custom components library.

This code is very generalized, much more so than you need. After all you already know the names of your DB and the Table. You aught to be able to simplify this code down to half the number of lines.

In order to get your code working like you want it to you're going to have to do some testing from the JavaScript Console window. In fact you should be doing the vast majority of your development from the console.

We can only answer simple to the point questions. Your code is much to complex for us to analyze it for you. If you are not up to doing the testing and development yourself you should seek professional help.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

gblodgett
Registered: Aug 21 2007
Posts: 4
Thanks for responding. I did get it to work beautifully. I was real excited until i tried to roll this out to one of my testers that has only Reader. It errors out in Adobe Reader. Is there some flag i need to set or is there some way I should save this so end users with only Reader can open this doc choose a field from the drop down and have it update the rest of the fields from the database? Any help is appreciated!

Thanks!

Greg
StephM
Registered: Aug 6 2009
Posts: 1
I'm new to acrobat forms and I lost 2 days searching how to connect to my database using javascript.
I need to fill a part of the form depending on the client number provided by the user.
then the user would enter some data and parts of it would be sent back to the database and the other parts would be saved in the form.

I read that adbc could connect to database but people with adobe reader couldn't use that because adbc is not defined for Reader. I think I need to use jdbc driver but I am still searching for a code example... a concrete example would be appreciated... maybe a pdf that I could download and look at the code behind.

Thanks!
Steph