Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

published pdf form is unable to connect with database

Avatar

Level 1

Hi Guys!

I have created a PDF form using Adobe Live Cycle Designer which have some text fields namely RECORD and NAME. I have connected this form with a Database. When I enter a record in the RECORD number field the NAME field of this form has been populated with the help of XFA Script which is written on the exit event of the RECORD text field. When we publish this form, a new interactive PDF is created which works fine and populates the NAME field from the an SQL database but when I access this PDF form (which is located on a shared location) from some another location (not on the same machine where i designed this form) it is unable to connect to the database and does not work as expected.

I think there is some thing i am missing for the database connectivity.

If any body on this forum can help me out.

thanks

Here is the Script for the above form which i used to populate the NAME FIELD on the basis of enetered RECORD number.

----- Document.Page1.txt_MRN::exit: - (JavaScript, client) -----------------------------------------

/* This dropdown list object will populate two columns with data from a data connection.

sDataConnectionName - name of the data connection to get the data from.  Note the data connection will appear in the Data View.
sColHiddenValue  - this is the hidden value column of the dropdown.  Specify the table column name used for populating.
sColDisplayText  - this is the display text column of the dropdown.  Specify the table column name used for populating.

These variables must be assigned for this script to run correctly.  Replace <value> with the correct value.
*/

var sDataConnectionName = "DataSource";  // example - var sDataConnectionName = "MyDataConnection";
var sColHiddenValue  = "RecordNum";   // example - var sColHiddenValue = "MyIndexValue";
var sColDisplayText  = "Name";   // example - var sColDisplayText = "MyDescription"


// Search for sourceSet node which matchs the DataConnection name
var nIndex = 0;
while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
//var oDB = xfa.sourceSet.nodes.item(nIndex);
var oDB = xfa.sourceSet.nodes.item(nIndex).clone(1);
oDB.open();
oDB.first();

// Search node with the class name "command"
var nDBIndex = 0;
while(oDB.nodes.item(nDBIndex).className != "command")
{
nDBIndex++;
}
// Backup the original settings before assigning BOF and EOF to stay
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");

// Clear the list
this.clearItems();

// Search for the record node with the matching Data Connection name
nIndex = 0;
while(xfa.record.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oRecord = xfa.record.nodes.item(nIndex);
// Find the value node
var oValueNode   = null;
var oTextNode   =  null;
var sRecordNum  =  $.rawValue;


for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++)
{
if(oRecord.nodes.item(nColIndex).name == sColHiddenValue)
{
  oValueNode = oRecord.nodes.item(nColIndex);
}
else if(oRecord.nodes.item(nColIndex).name == sColDisplayText)
{
  oTextNode = oRecord.nodes.item(nColIndex);
}
}
var found= 0;

while(!oDB.isEOF())
{
if (oValueNode.value== sRecordNum)
{
  txt_FirstName.rawValue = oTextNode.value;
  txt_LastName.rawValue = oTextNode.value;
  found = 1;
  break;
}
  //this.addItem(oTextNode.value, oValueNode.value);
   oDB.next();

   if (found == 0)
   {
    txt_FirstName.rawValue = "";
    txt_LastName.rawValue = "";
   }
}

// Restore the original settings
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction");

// Close connection

oDB.close();
form.JPG

3 Replies

Avatar

Former Community Member

Did you define the DSN that you created on the local machine on the machine that is accessing the form? Each machine must have a DSN with the exact same name so that it can leverage the ODBC data connections. Also the database driver for your particular database must be on each machine.

Paul

Avatar

Level 1

I have defined the DSN on the local machine that is accessing the form and this machine has DSN with the exact same name . The database driver exists on each machine but the same problem of database connectivity persists when i access the from from other machine.

Below mention is the encountered error of the Form

GeneralError: Operation failed.
XFAObject.open:22:XFA:Document[0]:Page1[0]:txt_MRN[0]:exit
Connection for Source "DataConnectionName we defined for Data View" failed because the environment is not trusted.

thanks

AbdulHafeez

Message was edited by: abdulhafeez001

Avatar

Level 1

Finally achived the database connectivity for the published pdf form developed in the Adobe LiveCycle Designer 8.0.

There must be the same driver version of the DSN on both machines. The machine which published the form and the one accessing it.

Use the Admin account to add the DSN on both machines.

Get rid of the error: Connection for Source "DataConnectionName" failed because the environment is not trusted.

Thanks

AbdulHafeez