Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

No sourceSet nodes in the change event??!, help!

Avatar

Former Community Member

I have Acrobat 9 pro and it comes with Lifecycle 8.2 ES

I decided to try the data drop down with an address block for a simple database hello world form.

I have read every web reference to this (on the surface) simple hello world style forms project.

In the process I’ve learned formCalc, accessors, clone(1), Ref, the XML form model, sourceSet,

binding, nodes, items, shortcut formCalc notation, form vars, defining OLEDB and OLEDB ODBC (tried both).

I’ve coded the change event at least 30 different ways using both formCalc and javascript.

I still can’t get this to work. I belive in RTFM but this has finally kicked my a** and I need some help.

I know what the problem is, I don’t believe it. The sourceSet node in the change event has 0 nodes even though I have two data connections and I can access them in the initialize event. Did they remove access to the sourceSet in the change event completly in Acrobat 9 and just didn’t tell anyone?

My database is SQL server with two tables.

  1. A customer table with Name and CustomerID
  2. An Address Table with CustomerId and address information

I set up the data drop down to display the Name and then in the change callback I tried to get the CustomerId
and query for the data in the second table. I’ve bound the address block data to fields in the second table and set the second table to delayed open.
I’ve tried this with every possible way of coding an accessor. When coded directly (using the intellsence thing) I get unknown accessor for the error. When using the index method and searching for it with a while, I get index out of range with an index value of 0.

Here is a formCalc version of the change callback:
========================
$host.messageBox(“In Change”)
var sName = xfa.event.newText
var sCustomerId = $.boundItem(sName)
var oDataConn = Ref($sourceSet.DataConnectionCRM.clone(1))
$host.messageBox(sCustomerId )
oDataConn.#command.query.commandType=”text”
oDataConn.#command.query.select = Concat(“SELECT [Name], Customer.[CustomerId], [AddressLine1], [AddressLine2], City, State, Zip FROM [DSD_JDEPROD].[dbo].[Customer] join [DSD_JDEPROD].[dbo].[Address] on PrimaryAddressId = Address.AddressId where Customer.CustomerId = ‘”, sCustomerId ,”‘;”)
oDataConn.open()
========================

This version of the code has the unknown accessor error at this line:
var oDataConn = Ref($sourceSet.DataConnectionCRM.clone(1))

I’ve coded this line many different ways using xfa notation, $sourceSet notation, resolveNode notation, but in the end it doesn’t matter
because this message box:
$host.messageBox(Concat(“sourceSet=”,xfa.sourceSet.nodes.items.length))

returns a 0 count in the change event.
I’ve check the XML and I have sourceSet in there and as I’ve said, the intellisense thing works and
the initialize callback works. The dropdown is correctly populated.

Note: I do realize I’m going to have to do something different in order to get the customerId as this:
var sCustomerId = $.boundItem(sName)
doesn’t work due to the way the initialize event populates the drop down. I’m sure I can fix that.
I just can’t get past the problem of no sourceSet nodes in the change event.

Thanks for your help!

7 Replies

Avatar

Former Community Member

Not sure I follow ....when do you want the data connection to happen ......am I choosing something from the DDList then that is used to query the DB?

Paul

Avatar

Former Community Member

Yes, the standard that everyone does. Select from dropdown and use the id (the bound data) to build a SQL statement for the second DB connection. I believe I coded it correctly but I can't get past the change to sourceSet 'cause there is no soureSet at that point. Should be, but there isn't. As I said, I've coded this at least 30 ways and just no sourceSet.

Thanks for looking at it,

Ed

Avatar

Former Community Member

I have done the samething and here is the code that I used .....are you by chance using Reader to run this form?

Paul

//get the input from the DDlist
var inName = xfa.event.newText;
if (inName == ""){
app.alert("You must enter a valid name - try again!")
}
var nIndex = 0;
while(xfa.sourceSet.nodes.item(nIndex).name != "DataConnection2")
{
nIndex++;
}

var oDB = xfa.sourceSet.nodes.item(nIndex).clone(1); // the node pertaining to the data connection specified
//app.alert(oDB.saveXML("pretty"));

//set up sql call to DB to get specifics about employee

oDB.nodes.item(1).query.setAttribute("text", "commandType");
oDB.nodes.item(1).query.select.nodes.item(0).value = "Select * from table1 where AcctNumber = '" + inName + "'";
//app.alert(oDB.nodes.item(1).saveXML("pretty"));

//now connect to DB and get a record
oDB.open()
//close the connection when finshed
oDB.close();

Avatar

Former Community Member

Apparently I was arrrrgg, newbie error. I was just clicking preview form and apparently reader was coming up. I launched acrobat and loaded the form instead of using LC. Now I just have the environment is not trusted error. I saw some posts on that error so I'll go look there. Also, as I understand it, if I want to use reader to run this DB connected form, I have to use reader extensions. Something else to look into. I consider this progress.

Thanks again,

Ed

Avatar

Former Community Member

To get around the trusted thing ...look at my code and sdo the clone technique.

Yes you are right ...if you want to use Reader then it must be RE with Livecylce Reader Extensions server ...not with Acrobat.

Paul

Avatar

Former Community Member

I have the clone(1) in there already. Adobe says I have to upgrade to 9 pro extended to be able to use reader to access a database. I'll try that a bit later.

Avatar

Level 10

Hi,

While you can apply reader extensions in Acrobat 9 Pro Extended (and Acrobat 9 Pro and Acrobat 9 Standard), users with Reader will still not be able to use the data connections to access the database.

The Reader Extensions that Paul is talking about is a different server component.

A summary is here at the end of this post: http://cookbooks.adobe.com/post_Using_LiveCycle_Forms_in_Acrobat_and_Reader-16518.html

Good luck,

Niall