Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

dynamically bind a dropdownlist with button Livecycle 8.2

Avatar

Former Community Member
Can someone please tell me why this code does not work? Nothing happens when I click the button. The dropdownlist populates fine when the form loads, but I cannot get it to repopulate. I have tried hardcoding the parameter with aLike, =, etc.



topmostSubform.Page1.Button1::click - (FormCalc, client)

var sCategoryId = sname.rawValue

var oDataConn = Ref(xfa.sourceSet.DataConnection.clone(1))

oDataConn.#command.query.commandType = "text"

oDataConn.#command.query.select = concat("SELECT * FROM oca WHERE last Alike '", sCategoryId, "'" )

oDataConn.open()

DropDownList1.#bindItems

regards

Milton
3 Replies

Avatar

Former Community Member
Not sure what you are trying to do with the bindItems call. Are you trying to change the binding of the dropdownlist on the fly?

Avatar

Former Community Member
Yes, I found the following example. I am trying to connect it to an access db. I tried the following code and I can see that at least one record is found with the select statement. However, the while statement does not populate the dropdownlist with any data. the last line is able to add one list item manually. Can you tell me what is wrong with this code? The oca table does have myname and id as fields. This formcalc script runs with a button click event.



var sCategoryId = sname.rawValue

var oDataConn = Ref(xfa.sourceSet.DataConnection.clone(1))

oDataConn.#command.query.commandType = "text"

oDataConn.nodes.item(1).query.select.nodes.item(0).value = concat("SELECT * FROM oca WHERE last Alike '", sCategoryId, "'" )

oDataConn.open()



DropDownList1.clearItems()

DropDownList1.rawValue = ""

while (-oDataConn.isEOF()) do

xfa.host.messageBox(xfa.record.DataConnection.inet.value + " " + xfa.record.DataConnection.ID.value)



oDataConn.next()

endwhile

DropDownList1.addItem("Milton", "21300")

oDataConn.close()

Avatar

Former Community Member
I posted the wrong code. I did not have the addItem inside the while Loop. I have been doing more testing. I now see the problem is the while statement. What is the correct syntax for:

while (-oDataConn.isEOF()) do



var sCategoryId = sname.rawValue

var oDataConn = Ref(xfa.sourceSet.DataConnection.clone(1))

oDataConn.#command.query.commandType = "text"

oDataConn.nodes.item(1).query.select.nodes.item(0).value = concat("SELECT * FROM oca WHERE last Alike '", sCategoryId, "'" )

oDataConn.open()



DropDownList1.clearItems()

DropDownList1.rawValue = ""

while (-oDataConn.isEOF()) do

DropDownList1.addItem(xfa.record.DataConnection.myname.value, xfa.record.DataConnection.ID.value)



oDataConn.next()

endwhile

DropDownList1.addItem("Milton", "21300")

oDataConn.close()