Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reset inputfield to initial value

Hi,

I'm having a problem using the InputField function. Basically, I have a Yes/No field (it's really a text field with either "Y" or "N") that I load twice, once normally ("To_Pay") and and again as an Input Field ("Will_Pay"). The purpose for the field is to indicate whether a payment should be made. The idea is that the user can see what the source file has and override it if necessary via the second instance of the field. The resulting table will show only the overrides and will eventually be used to update the originating program. It works but I seem to be having a few challenges:

  1. If I reload from the same or similar data, some of the changes to the input field seem to persist. I would have expected them to reset back to the original values on a reload.
  2. I would like to create a command button to reset Will_Pay on all rows to the original value from To_Pay, in case things get so messed up it would be easier to start over. I suppose if #1 gets fixed, that might a way to do this, too.
  3. When I use both fields in a multi-box, the drop-down for To_Pay shows only one of each Y or N as expected, but the drop-down for Will_Pay shows many Ys and Ns. I haven't counted but I'm guessing it's one for each row.

Any ideas, or am I just trying to use this in a different way than it was intended?

Thanks,
Dino

BTW, I'm using 8.01, planning to use 8.50 soon.

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP


Dino Bekas wrote:If I reload from the same or similar data, some of the changes to the input field seem to persist. I would have expected them to reset back to the original values on a reload.


Correct, Input Fields are designed to survive reload. There is a problem, however... The Input Field values are not linked to the logical keys, but rather to the Row number. If you reload new data, and some of the new rows get inserted between the old rows, the entered values will get attached to the wrong keys.


Dino Bekas wrote:I would like to create a command button to reset Will_Pay on all rows to the original value from To_Pay, in case things get so messed up it would be easier to start over. I suppose if #1 gets fixed, that might a way to do this, too.


Yes, you can use APIs to reset inputfield values. Look in the API Guide for a member "ResetInputFieldValues".


Dino Bekas wrote:When I use both fields in a multi-box, the drop-down for To_Pay shows only one of each Y or N as expected, but the drop-down for Will_Pay shows many Ys and Ns. I haven't counted but I'm guessing it's one for each row.


Yes, unfortunately this is how it seems to work... I found the following "work around" - create a list box with the calculated Expression - for example, left(myInputField, 1). This seems to work correctly - only distinct values are displayed, and the selection works as expected.

regards,

Oleg

View solution in original post

8 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP


Dino Bekas wrote:If I reload from the same or similar data, some of the changes to the input field seem to persist. I would have expected them to reset back to the original values on a reload.


Correct, Input Fields are designed to survive reload. There is a problem, however... The Input Field values are not linked to the logical keys, but rather to the Row number. If you reload new data, and some of the new rows get inserted between the old rows, the entered values will get attached to the wrong keys.


Dino Bekas wrote:I would like to create a command button to reset Will_Pay on all rows to the original value from To_Pay, in case things get so messed up it would be easier to start over. I suppose if #1 gets fixed, that might a way to do this, too.


Yes, you can use APIs to reset inputfield values. Look in the API Guide for a member "ResetInputFieldValues".


Dino Bekas wrote:When I use both fields in a multi-box, the drop-down for To_Pay shows only one of each Y or N as expected, but the drop-down for Will_Pay shows many Ys and Ns. I haven't counted but I'm guessing it's one for each row.


Yes, unfortunately this is how it seems to work... I found the following "work around" - create a list box with the calculated Expression - for example, left(myInputField, 1). This seems to work correctly - only distinct values are displayed, and the selection works as expected.

regards,

Oleg

Not applicable
Author

Thanks for the explanation, Oleg. Unfortunately, I don't seem to know enough about using the API guide to understand ResetInputFieldValues. I tried to use the example provided but get some sort of parsing error whenver I try to save.

Also, I can't figure out how to create a calculated field in a list box. I can create one in a chart, but not a list box.

Sorry to be so dumb...
Dino

Not applicable
Author

Dino You can create the calculated field in the list box by

right click on the qlikview document and select New sheet object then list box and in general tab on fields drop down list select expression from the list

Talha

Not applicable
Author

Yep, the macro did it, as well as the list box idea. Thanks to both of you...

Dino

etay_netintent
Partner - Contributor III
Partner - Contributor III

HI Dino

I have seen your discussion and am stuck with the same problem.

Can you send me the macro that evenually worked ??

Thanks

Etay Elazar

QlikView-Israel

Not applicable
Author

Hi Etay, sorry so late in replying. Here's the macro that works for me. The field I'm resetting is "LiabDetail.Will_Pay".

sub Reload
ActiveDocument.ReloadEx 1,2
set f = ActiveDocument.Fields("LiabDetail.Will_Pay")
f.ResetInputFieldValues 0
end sub

Dino

klausskalts
Partner - Creator
Partner - Creator

Hi

The problem with teh API example is - as I understand - that it resets a single value.

You would like to reset all values - I presume:

sub resetinput
dim x(1)
x(0) = 0 ' element to reset
set fld = ActiveDocument.Fields("Index_Pris_Simulering")
fld.ResetInputFieldValues 0, x ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value
end sub

regards

Klaus

Not applicable
Author

Hello,

I've seen your discussion and i'm also facing the same problem. I've developed my qvw file with below script.

INPUTFIELD MinTakeOver,MaxTakeOver;

TakeOver:

LOAD  TakeOver,MinTakeOver, MaxTakeOver, MinTakeOver as MinTakeOver1, MaxTakeOver as MaxTakeOver1;

LOAD 'BCButtterflyTimeA' as TakeOver,

max(BCButtterflyTimeA) as MaxTakeOver,

min(BCButtterflyTimeA) as MinTakeOver

From

T.qvd

(qvd);

- I kept schedular for this file to reload every day for once. What i've seen is input fields are not updating with latest qvd data. It is holding previous qvd data only. As you said that input fields will not update but how can i over come this. B'coz in my application around 300 input fields are there. More over i'm using this input fields in tablebox to change and in listbox expression to see the values.

Please share your idea how to achive this. It is very urgent for me.. Other wise is there any way to achive.

whether possible or not.