Expand my Community achievements bar.

SOLVED

How do I make a data connection object variable?

Avatar

Former Community Member

This should be easy but I can' t sort it out.

I created a database connection and cloned it so I could avoid security issues.

The cloned connection works fine and I can query for specific records and the bound fields are populated. The problem comes when I try to advance to the next record with "clonedDB.next()" for example. The error that says "clonedDB is not defined". This code is all in Java by the way.

So I though maybe I need to create an object variable to contain the clonedDB object; this is what I can't figure out how to do or if will solve my problem.

Thanks in advance!

Cheers,

Al

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Can you send me your form so I can have a look?

If the attachment ability is not available for you can you email it to LiveCycle8@gmail.com

Thanks

Paul

View solution in original post

9 Replies

Avatar

Former Community Member

Are you doing this in the same script or from a differnt script?

Paul

Avatar

Former Community Member

Hi Paul,

If I understand your question correctly; I am trying to move to the next record in the record set from a button with the clonedDB.next() statement in the script. This button is not the same button I use to query the data connection for the record set.

Cheers,

Al

Avatar

Former Community Member

The cloned set is only available while you are in that script. To go to the next record you woudl use:

xfa.sourceSet.YourDataConnectionName.next()

Paul

Avatar

Former Community Member

Hi Paul,

I tried to use the next() command as you suggested but I get this error:

"next operation failed, because there was no connection specified"

Is it possible that because I cloned the dataconnection the script will not access the actual dataconnection?

If I can make a form variable and assign it to the cloned dataconnection I should be able to access it from any script on the form until I close the connection; I just don't know how to do it.

Cheers,

Al

Avatar

Correct answer by
Former Community Member

Can you send me your form so I can have a look?

If the attachment ability is not available for you can you email it to LiveCycle8@gmail.com

Thanks

Paul

Avatar

Former Community Member

Hi Paul,

This works! To make the "Previous" record button work I just had to change the connection type to Dynamic and now I can move back and forth through the records.

Thanks a bunch!

Al

Avatar

Former Community Member

Do you need an explanation of why it works or are you OK with what you have?

Paul

Avatar

Former Community Member

I think I understand that the cloned DB you made into a form level variable

when the function initDB is called as the form is initialized (I think).

So the data connection object variable (myconnectionobject) exists as long

as the form is open and can be accessed from within other form objects and I

should have access to any of the data connection methods and properties when

referencing myconnectionobject variable.

Am I correct?

Cheers,

Al

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----