Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have learnt here in the Community that I can define a variable in the script so that it is filled with a value on the GUI, basically using two equal_signs and the 'SET' command.
Usually that works fine. For some reason, however, it doesn't work in an app I am currently working on.
Maybe one of you can imagine why that is or where the error is.
In the app I'm working on, there is a rather large straight_table_chart. To make it clearer, I want to give the user a possibility of selecting which fields he/she wants to see.
Now, in my app, I have a field >> __fields_to_display << from an Inline_table. That has a Hide_Prefix so it doesn't show up in a statusbox which would be quite confusing as this is not a selection supposed to limit the amount of data.
<=> What this actually does (or is supposed to do) is that for every field in this Inline_table, there is a variable. That is supposed to query the presence of this field in the output of a Getfieldselections() command and if any field is present, the corresponding variable should take on the value 1, otherwise it should be -1.
The code in the script is like this:
>> SET v_show_calculation = = IF(INDEX(Getfieldselections(__Detailfelder), 'Berechnung') > 0, 1, -1) <<
It seems not to work - at least, not reliably, not always.
I'll try out if it might be because of the Hide_Prefix. Though I have tried out that Index() function and it works reliably on the GUI.
Thanks for any ideas!
Best regards,
DataNibbler
Hi,
ok, I fixed those other conditions now.
I still face the following issue:
- I can click any one of all the fields (in that listbox) and the variable toggles like it should.
- When I click up to 6, those 6 variables all toggle to 1. The rest remain at -1;
<=> When I click a 7th one (any one), all the variables snap back to -1 ...
Is there a limit on the number of values that I can select simultaneously? Can I change that somewhere?
Thanks a lot!
Ah - six is the standard limit of the Getfieldselections() function 😉
OK,
this is done. There was again some confusion with outdated variables that I had not thought of deleting.
I just opened the variable_manager, deleted them all (that is why I now prefer defining variables in the script, even those supposed to be populated only on the GUI) and then reloaded the script.
Strange - it seemed to be fine, but now ...
I have checked everything again and again. All the variables are in place - and when I test them in a textbox, they work fine and the table_chart reacts to them all right.
Somehow, my "selection box" seems to be a bit whacky - that is actually a listbox that I have set to have three columns and on the presentation tab of the dialog, I have set the representation to "Windows control boxes" (I hope that's right, mine is in German). That doesn't seem to work somehow - some of the variables just don't seem to care whether or not I select a certain field ...
Very strange.
DataNibbler,
it would make things a lot easier if you upload a small sample QVW.
Hi swuehl,
yep, I know. That is usually so. The trouble is, when you have some more complex constellation and you assemble an example in order to show how something does NOT work, it tends to work fine for other people 😉 At least, that is my experience.
I'm just experimenting with other layout_options for that "selection_block" - but that doesn't seem to make a difference - nor should it ... I just chose that "Windows control boxes" visualization because it looks good and allows you to select several fields without holding the SHIFT key. I can click up to about five fields and those five fields show up in my chart all right. Then I click another - and my chart snaps back to showing just one field ... The variables do not switch back, only the chart ...
My suspicion was that the Getfieldselections() might not work reliably with fields that have the Hide_Prefix - but I had to discard that, the function works fine in a textbox. I have already tried creating all the variables on the GUI, that works fine, and then I have copied the code into my script and adapted it a bit - which does work - but something doesn't and I have no idea what it is.
There are basically three steps here:
- The first is an Inline_Table with all the fields that I have that can be displayed in the chart.
- Then come the variables that query whether or not one of the fields (which are the values in that Inline_Table)
has been clicked - then the variable is 1, otherwise it is -1
- When any of the variables is 1 (and another condition that essentially queries whether there is a point in
displaying that field returns TRUE), that field is displayed in the chart (I have activated a condition on the "formulas" tab
of the dialog (I think that is better, resource-wise, than having the condition on the "presentation" tab?)
The code in the script that creates the variables is like this (example for a date_field)
>> SET v_show_date = = IF(Index(Getfieldselections(__fields_to_show), 'date') > 0, 1, -1) <<
=> Robust actually, I had that before - so the variable is populated only on the GUI; When, in the field
> __fields_to_show < (that has the Hide_Prefix) the user selects the value 'date', that variable should switch to the
value 1 (otherwise it should be -1) and that should trigger that field to be shown in the chart.
Okay, there is another condition attached to the display of the fields and I will check that, but that is less complex - just one out of three different conditions that I have put into variables - and I think there is no error there.
Well, it's friday afternoon and I think I'd better be off now. Maybe on Monday I'll have a new idea.
I'm sorry, I know I'm not making it easy for you to help me - but as I said, in my experience, re-building an error in a sample for other people is quite hard when you don't know just what the error is ...
Have a nice weekend!
Best regards,
P.S.: Now I attach a small sample file that I have put together to demonstrate how this is supposed to work - but just like I said, this one works perfectly. So it will help you understand just what I'm trying to achieve, but it won't show you the wall I am hitting. That might have to do with the nr. of fields I have in the real app - though that's not soo many - or the amount of data - for some reason, the table in my app takes a while to calculate and can even freeze the computer if there's too much data - so I have built a button to keep it from being recalculated while the user does some other analysis. Whatever limit I'm hitting with this chart might be the reason why that variable-thingy isn't working ...
DataNibbler
Hi,
okay, I think I'm not getting anywhere with this. I just cannot imagine what it might be that's keeping this from working like it should.
So I'll have to find another way to achieve what I want:
=> The objective is to give the user a way to select, out of the 50 or so fields there are, those he/she wants to see (this
table is for viewing the detail records)
Can you suggest me another way that I might do this?
Thanks a lot!
Best regards,
DataNibbler
Sorry, I didn't get in all this text what is happening or not happening in your original QVW when 'it's not working'.
You select in the list box a field name and it's not showing up? Or you deselect a value and it's not disappearing?
I think you should be able to tell if this is an issue with variable evaluation (just check all variables in an input box) or the conditional evaluation in expression tab.
Hi swuehl,
no problem. I don't quite understand myself what is or is not actually happening, I only know how it's supposed to work. I will try once again to describe that and then I will look at my app once again to check the individual steps.
- The whole thing is about checking calculations in two files - one from, say, >company< and one from >customer<
- I have a listbox with all the fields which are loaded from the original Excel file(s) - say, there is a field
>ship_date_company<.
- The customer should be able to choose whether he/she is interested in this or not - thus, if it should be displayed
or not.
- There is a variable >v_show_shipdate< that can have either the value 1 or -1
=> When this variable has the value 1, the field is displayed, otherwise it is not (there is a condition on the
'formula' tab of the dialog)
=> Now, when the user clicks this field in the listbox, the corresponding variable should toggle from -1 to 1 and the
field should appear. As soon as he/she de-selects it, the variable should toggle back and the field should
disappear. That's as easy as it actually should be.
There is, however, one other condition which I will also check now:
- There can be records which are present in the >company< file, but not in the >customer< one and v.v.
- Now, obviously seeing the >ship_date_company< would not make sense when the user is just reviewing
records which are not present in the >company< file (in that case, that field would not show anything)
=> For that reason, there are three conditions, one of which is combined with the former:
- " Show only when >company< or both are selected
- "Show only when >customer< or both are selected
- "Show only when both are selected
Because these conditions (one of them) are re-used in every field, I have put them into variables.
So much for >how it should be< 😉 The little example file I have put together works just like that, and it works perfectly - but the real one doesn't. I have no idea why, it is built identically as far as I can tell. I will have another look.
Best regards and thank you,
DataNibbler
Ah,
I just noticed those other conditions - which define whether or not it makes sense to view a specific field - do not seem to work. Now, that does not mean that the others do work, but it is one trail that I can follow ...
Hi,
ok, I fixed those other conditions now.
I still face the following issue:
- I can click any one of all the fields (in that listbox) and the variable toggles like it should.
- When I click up to 6, those 6 variables all toggle to 1. The rest remain at -1;
<=> When I click a 7th one (any one), all the variables snap back to -1 ...
Is there a limit on the number of values that I can select simultaneously? Can I change that somewhere?
Thanks a lot!
Ah - six is the standard limit of the Getfieldselections() function 😉