infopath: hide control if all choices are filtered away - infopath

In infopath, I have a choice box that gives a choice of values from a secondary data source that is filtered.
How can I make the control hide if there is nothing matching the filter?

You can you use the count function to set a field to the value of the count of the filter, then hide the control if that field reads 0.

Related

In App Maker, can you fake valueIsRecord with a dropdown field?

In App Maker, what is the simplest way to achieve the same result with a dropdown box that you can with a suggest box, which can return the whole record when you make a selection giving you the ability to assign associated record values to other fields on the page?
Consider a data model with three fields, (Code, Description, and Severity). Add a dropdown box to select the Code. Have the selection, (probably using onValueChange or onValueEdit), write the selected Code's Description to a label field beside the dropdown box. The Code's Severity will also be used to affect the style in some way like background color or something, but for this answer, merely assigning the value to a scripting variable will be good enough. It's the record value access and assignment mechanism I am after.
Clarification: This data model will not be the page's datasource. It is a secondary reference table used for assigning a code to a ticket. You can also assume that a record value will be written to a field in the page's datasource as well.
I would appreciate the simplest low code solution as we will have non-programmers attempting this. Thanks.
As long as you leave your value binding on the dropdown blank the following should work:
Set the options binding to:
#datasources.YourDatasource.items
You may want to consider changing the 'Names' binding to be the projection of a particular field in this datasource otherwise the values showing in your dropdown will only be the 'keys' from this datasource.
Then in your onValueEdit event you will gain access to individual fields like this:
var item = widget.datasource.item;
item.YourFieldToEdit1 = newValue.YourOtherDatasourceField1;
item.YourFieldToEdit2 = newValue.YourOtherDatasourceField2;
That would probably be the simplest way.

Filter and Bind a Multiselect

I am trying to implement a Many-to-Many relation between a class and its students in a form.
The form can be used to create or edit a class. Also students can be added to that class. To reduce the effort needed to enter students, I would like to add a multi-select that shows the entries from the students-table. But since the number of students is expected to be large, I would like to filter this multi-select.
I checked this question on filtering lists and the sample app "Project List. I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains and set the tables datasource property to STUDENTS
But, as I understand it, a multi-select element's value property must be bound to #datasource.item.students and its datasource property must be CLASS in order for the auto-saving to work.
Hence I wonder whether it is possible to filter a multi-select element.
I don't see the problem, but I think I see a misunderstanding.
You said: "I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains"
You need to bind the OPTIONS (not value) to the datasource query, as it is the options that will draw its records from the #datasources.Students.query datasource.
You can then set the VALUE of the multi-select widget to #datasource.item.students (where you want selected values from the student query options to be saved).
You will also need to set the NAMES property (since the options are likely student records). Names will be the Student datasource projection of whatever string field you want to appear in the options list.

How to check if multiple rows have been selected in a grid

How can I check if multiple rows have been selected in a grid?
In Dynamics Ax, there a multiselect property that disable button if multiple records have been selected, does the "opposite" exists?
Meaning activating a button only if multiple records have been selected, how can I do this through code?
Unless that kind of property exists, it seems you have two things here :
check if multiple rows are selected
check it every time the selection changes
Checking for multiple selection
Have a look on axaptapedia : Multiple grid selections to count the selected records.
Checking on selection's change
Look at the InventTable's form where buttons are activated depending on the selection being a bom or not.
Form's methods handling buttons activation like setBOMRouteEnabled are called from datasource's method active.
Following this model you can check for multiple selection on selection's change.
The best way to detect this would be like this:
FormDataSource fds = salesTable.dataSource();
if (fds.recordsMarked().lastIndex() > 1)
info("Multiple records selected");
else
info("1 or 0 records selected");

Conditional fields and views

I have five multigroup fields each one are displayed by a conditional field with a 1 to 5 value. If I select for example 2 there's a select list field appearing with is selected data , if i select 1 there's another one with an another select data.
How do I display with wiews only the content of the choosen value of the conditional field.
Thank you.
The simplest way of doing this, would be to create the logic in your theme. There are many ways of doing this, one would be to add all of the possible fields, but exclude them from display, and only show the conditional field. In one of the preprocess functions for the view, you could check the raw data for the conditional field, and replace either the field, or just the the themed value, with the value of the field you want to display.

Drupal Views and exposed filters - how to reset optional drop-down list filter, or allow "all" selection

I have a view with a filter by country. Country is an optional CCK text field with drop-down list selection from a predefined list.
When I expose the field as an optional view search filter, I can select a country on the filter form just fine, but how can I handle no selection? I want the user to be able to "un-select" any previously selected value so that the query runs for all countries (or, to be more precise, does not constrain the results by country). I cannot add "all" as a value to the CCK field for obvious reasons. Selecting all countries in the drop-down on the search filter is not very user-friendly and causes the page to time out (there are over 200 countries in the list, and I can only imagine the resulting SQL query). Whats the best way to handle this?
I found this View Filters Reset hack which could be helpful. The desire to memorize the last selection adds another complication - when configured in the View properties, and once the (persistent) cookie is set, there is no way to get rid of the selection (short of manually deleting the cookie).
The answer was to check "Force Single" on the filter properties. This made <any> show up as a selection in the country filter drop-down. It kind of makes sense, because <any> in a multiple-selection list could be seen as ambiguous. Still, I can think of valid reasons why a multiple selection filter might be optional. Drupal surprises me every day.

Resources