The main idea is to create a search funcionality on a form. I want to move to the next record until I find what Im looking for. Heres the code:
// These variables get the numeric values of both the NumericField5 and NumericField8. NumericField5`s rawValue will be less than the NumericField8`s.
var strt = NumericField5.rawValue;
var end = NumericField8.rawValue;
// While strt variable rawValue is smaller than the end variable rawValue, move to the next record in the DataConnection.
while (strt < end)
{
xfa.sourceSet.DataConnection.next();
strt = NumericField5.rawValue;
}
Solved! Go to Solution.
Views
Replies
Total Likes
You can store the content of the field before entering the loop then use a for loop to wait until it has changed. Then you would update the stored content with the new value so that the next time through you are waiting on the right thing.
Paul
Views
Replies
Total Likes
"end" may be a reserved word. Try using something like numEnd, for example, as your variable name.
Views
Replies
Total Likes
Yea, sorry, i had other words there, put those just to simplify reading. wont still work.
Views
Replies
Total Likes
Is the form trusted? The data connection may not work unless you've added the form as a trusted form.
Views
Replies
Total Likes
Remove the while loop and add a button to get the next record. Cycle through the records to make sure your condition is being met. Ciuld be that you are in an infinite loop.
Paul
Views
Replies
Total Likes
pguerett , i need that while loop to go right to the record Im looking for. If I remove the while loop , xfa.sourceset.dataconnection.next(); works just right, but I have to click one by one.
This is trusted, since it works when I click on a button with xfa.sourceset.dataconnection.next();
Views
Replies
Total Likes
The first (start) variable got the charcodeAt on the first 3 characters of the dataconnection, converted to strings, added , then converted to numbers.
The second (end) variable got the charcodeAt on the first 3 characters from an xfa.host.response dialog box, converted to strings, added , then converted to numbers.
Views
Replies
Total Likes
Understand what you are saying and I agree ....I am simply trying to validate that the condition that you set up in your
while loop will be met. By having you press the button for the next iteration in the while loop hopefully we can see what is happening ....my guess is still that you are in an infinite loop.
paul
Views
Replies
Total Likes
Hey Paul, forgot to tell you that the code is implemented on a button.
I added two more textfields that got the value from both variables. Removed the while loop, and the textfields show how start value goes up to end value until they match as I click and go to the next record.
Thats the weird part, they do get to have the same value after some iterations but still will freeze.
Views
Replies
Total Likes
They will still freeze when you remove the while loop or only when the while loop is implemented?
Paul
Views
Replies
Total Likes
It works well when I remove the while loop...
Views
Replies
Total Likes
So I think it is a timing issue. When you retrieve the record from the DB you may be moving onto the next statement in your code beofre the record is retrieved and the fields are updated. We need some way of knwoing that the record is ready. Can you add a test tho the loop to validate that data has changed on a field before doing the test?
This is just a theory but it would explain why Acrobat is being unresponsive ....
paul
Views
Replies
Total Likes
Paul:
Can you add a test tho the loop to validate that data has changed on a field before doing the test?
What do you actually mean here? I need to check the timing but didnt get the complete picture. Thank you.
Views
Replies
Total Likes
If a field changes each time you access a new record then you should be able to get the new record, then test the value of the field to see if it has changed, if it has then do your while loop test. This ensures that the new record has been retrieved and is ready to go.
Paul
Views
Replies
Total Likes
Ah, got it. Im only able to check if a field has changed on the change event and this script is only on the click event... if only i had some method to verify the change on the same click event i would try that on an if sentence right away.
Views
Replies
Total Likes
You can store the content of the field before entering the loop then use a for loop to wait until it has changed. Then you would update the stored content with the new value so that the next time through you are waiting on the right thing.
Paul
Views
Replies
Total Likes
Paul, Just like you said. Timing... THANK YOU!!!
Views
Replies
Total Likes
Views
Likes
Replies