Discussion Board for collaboration on QlikView Scripting.
I have a problem with one of my applications that creates a pdf report and send the pdf to an email address included in the datamodel. I loop over 3 fields and lock the values before i create and send the pdf.
Loop 1 = plant
Loop 2 = route
Loop 3 = driver
I use the getPossibleValues.Item(0).Text function to put the email address in a vb variable - the last loop field (driver) has only one value in the email address field so I don't need to do a loop over the possible values. 99% of the times this works like a charm, but for some very strange reason 1% of the times the email address fetched is incorrect. The GetPossibleValues.Item(0).Text returns a totaly different value that the one (and only) existing value in the email address field.Before i set the vb variable to use for the email function i also clear the vb variable to be sure that there is no "left overs" from the previous looped fields.
When the incorrect email is fetched, its very often the same driver (about 80% of the times).
I have checked the QVD and the email address is always correct (and only one value exists) and I cannot find a pattern to which incorrect value Qv chose to fetch.
Has anyone encountered the same issue?
In short, my script looks like this;
for i = 0 to Plant.Count - 1
select and lock Plant Value
for j = 0 to Route.Count - 1
select and lock Route Value
for k = 0 to Driver.Count - 1
select and lock Driver Value
GetPossibleValues.Item(0).Text on email address field
clear and unlcok Driver Value
clear and unlock Route value
clear and unlock Plant Value
I am facing the same issue.
We have some code that worked flawlessly when performing a similar email lookup to email a PDF in QV10. It seems that after migrating to QV11, we began facing this issue of the incorrect email being returned periodically.
Did you ever figure out a solution?
I actually found the issue a few days ago. It wasn't the GetPossibleValues function that wasn't working, it was the the select statement i had before. I've added some code a few weeks ago to be able to narrow down the issue by running the GetPossibleValues in a loop, and if the value were incorrect (i loaded the email values in two fields and compared those two) after 5 tries (with a sleep of 2sec between) I saved the application under a different name.
With this i could open up the application with the exact same selection state when the wrong email was fetched. In here i could see that QlikView had selected all my dimension values that started with the number 2, instead of just selecting number 2. And when about 8 dimension values was selected, the GetPossibleValues.Item(0).Text would of course most likely fetch the "wrong" address.
Havn't had time to find a solution or file a support ticket to QT Support but will follow up in this thread as progress goes on.
Just send me a pm if you want me to share the code with you.
I can't tell from your psedo code what may be wrong with the select, but it's a good idea to call Application.WaitForIdle between user actions like select and lock.
Yea, I had both the Wait4Idle and Sleep before my getPossibleValues, but when i started the error findings i also included a lock after the select, will include a Wait and Sleep between the select and lock.
I did somehow get this to work yesterday by making a few code changes (adding some additional selections). But perhaps the additional selections just added enough of a delay to allow the selection to complete. I will try using the WaitForIdle after selections.
I have now created a ticket in QFORCE, it will most likely take some time for them to respond as this topic is not covered by the Support & Maintenance agreement. Hopefully they will understand the huge impact this has once they start looking into the case.
I have done some more investigation but havn't found a solution yet. The good thing is that i was able to reproduce the issue so I had something to send to QT.
It is not the getPossibleValues that fails, its actually the Select statement. I have included both Sleep and WaitForIdle without any change. Even a sleep 10000 did the trick. As of now the I have some code to check that only one value is selected and if not a have a do while loop that redo the selection up to 5 times. After 5 times the application quits. Most often the macro will work upon next execution.
Post will be updated once i receive answers from QT Support.