Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This is pretty basic but I just can't seem to make it work. Before I load the field in my script I have:
inputfield [Corebio Custom Selection];
Then I have a macro that does the following:
sub setCSToOne
set fld = ActiveDocument.Fields("Corebio Custom Selection")
fld.setInputFieldValue 0, "1"
end sub
I run the macro and it does nothing. This seems like it should be pretty straightforward but it doesn't seem to work. Any ideas? Thanks.
hi Peter,
What are you trying achieve. There might be easier way than using a macro. If you can explain in detail then we might be able to provide you a better solution.
Deepak
Hi Deepak, all I'm really trying to do is set the input field equal to 1 for the people currently selected.
Thanks.
Clarification - the input field actually doesn't even have to be set to 1. Really it can be anything, or any range of values. I know there are several different methods in the API that refer to inputfields:
SetInputFieldValue
SetRawInputFieldVector
DistributeInputFieldValue
ResetInputFieldValues
Does anybody know anything about any of these? Aside from ResetInputFieldValues I can't seem to make any of them work.
Quick note: I am able to edit the values of [Corebio Custom Selection] in a table box so I know that I've at least succeeded in making it an inputfield.
Thanks very much.
For the sake of anybody else who runs into this problem and happens upon this, I'll post what I've managed to figure out:
SetInputFieldValue: Sets the value of the inputfield for 1 record:
set fld = ActiveDocument.Fields("Corebio Custom Selection")
fld.setInputFieldValue 3, "555"
This sets the value of fld to "555" for the 3rd record. The kicker is I'm not sure what field the offset, in this case 3, corresponds to. So it's changing the "3rd" record, but 3rd when ordered by what? No idea. It doesn't appear to be the table key and it's not the input field itself, thus this is pretty much useless until that’s figurd out since it’s impossible to spoecify which record you’re changing.
SetRawInputFieldVector: Sets the inputfield value for several records to the values in an array. Here’s an example from the API:
set f = ActiveDocument.Fields("Corebio Custom Selection")
set fv = f.GetNoValues
fv.Add
fv.Add
fv(0).Number = 11
fv(0).IsNumeric = true
fv(1).Number = 44
fv(1).IsNumeric = true
f.SetRawInputFieldVector 0, fv
In this case it’s setting the value for 2 records to 11 and 44. Again, though, I don’t know what field the offset, in this case 0, is referring to.
ResetInputFieldValues: Resets the input field's values to what they were originally set to in the load script.
NOTE: As it mentions in the documentation, all values in input fields are treated as unique, so if you happen to have several records with the same value, you can't select them all by that value. If the field is numeric, then a workround would be to select by using the greater and less than symbols, this seemed to work.
Thanks to deepak and anybody else who glanced at this.
Thanks for this very useful research Peter.
I'm trying to use the SetInputFieldValue command, because the more popular SetInputFieldCell does not work for me under Ajax and this more limited command seems to.
Can anyone offer any further insights into what sort order the SetInputFieldValue command parses an InputField list ?
Also, I noticed in one test that a field value that was out of scope (i.e. was greyed out) was changed. This doesn't appear to be consistent with other QlikView functionality so if anyone that can confirm, deny or offer an explanation about this it would be much appreciated.
Jonathan
Bumping this topic to the top. I too would like to assign values to an input field using a macro. Has anyone found a way to make this logically work????
I too would like to know a method of assigning a value to an input field...and preferably many at the same time...