Action Buttons on Form Pages (BETA)

I am beta testing unreleased improvements in Five. Jason explained how to add action buttons on a form or list. He also stated that I could put these buttons on the top of the form, and also pages on the form. I can’t figure out how to do the latter.

I can put buttons on the top of the form. My use-case is to have a form for my reports. There is a General page showing the report name. There is a Join page showing which study groups are attached to the form, using my ReportGroups join table. Now it shows every group on the join page, and those who have an entry in the join table will show as true on their checkbox. If I click another group in the join table, it will switch to true and add a record to the join table. This is working good now.

What I want to do is have a “Select All” button and a “Select None” button which will add all group records to the join table or remove all from the join table. This could be accomplished via a function which would update the join table.

It doesn’t make sense to have these buttons at the top of the main Reports form, because I will need multiple join pages on the form, each one of which will need these buttons. So how do I add action buttons to the top of a form page? I tried adding action buttons on the definition of the form itself (the one used as a join page on the Reports form), but they don’t show on the join page. There is no “Action Buttons” section available on the page itself. But Jason said it could be done. Please advise if I misunderstood him. Thanks…

Hi Ron,

the page type “Join” doesn’t support action buttons, unfortunately. So you won’t be able to add these buttons above or below the join. Users will have to select/deselect all records that they would like to include in their report.

Thanks for the answer, even if it’s not the one I wanted. How about this: If I make page navigation “Top” then is there a way to add action buttons that only show if a particular page is active? So if page 2 shows my groups, could I have “All Groups” and “No Groups” buttons on top of form whose ShowIf formula refers to the page 2 being visible/active? If so, could you suggest a formula?

Will other page types l, such as Action, support action buttons?

Thanks…

Ron Mittelman

Hi Ron, you could try to use the “Show If” condition on the page level of your form, i.e. go to Visual > Forms > Select the form that has multiple pages > Go to the page you wish to show/hide > provide a condition in the “Show If” box.

The syntax for the ShowIf condition follows the standard syntax for our showif fields: Show If | Five | Low-Code For Real Developers

Thanks for the reply, Dom. It seems like you are answering my other question in the forum topic “Hide a sub-form page by parameter”. That is not yet possible until the “ShowIf” parameter is available.

The question I’m asking here would apply to the “ShowIf” parameter of an action button. Here is my use-case:

GenerateReports form has 3 pages, General, Groups and Portfolios. The latter 2 will be Join type pages. I really want a “Select All” button and a “Select None” button, so users don’t need to scroll through 100 groups and flip switches for every one. I would love to be able to have “Select All” and “Select None” on the top of 2nd and 3rd pages, but Action buttons only appear at the top of the form itself.

So either have 1 “Select All” and 1 “Select None” at the top of the form, and have the code behind them be sensitive to which page is active, OR have 2 sets of these buttons, with only 1 set visible if the Groups page is active and the other set visible if the Portfolios page is active. Either way could work, and I believe both methods must be aware of the active page, right?

So is there a way to determine which page of the form is currently active? I think it would require TOP navigation rather than CONTINUOUS navigation, but not really sure about that.

I hope I made my question clearer. Thanks again for replying.

I realize you folks are very busy getting new releases out, but if you could answer the one question, I could continue my training and development.

Is there a way to determine, via stack or context or whatever variables, which form page is active? If that is possible, I could make my action buttons work for the desired page. I presume this would only work if my pages used top navigation rather than continuous, but please correct me if I’m wrong. Thanks…

Hi Ron, we’re just testing this on our end. I will get back to you later today to see if your idea can be implemented.

Hi Ron, thanks for your patience! We just discussed this feature in our weekly product meeting. Currently this isn’t supported, but we have added it to our roadmap.

Thanks Dom. Appreciate the answer. I may have a way to accomplish what I want, but it requires an answer to a question:

I have a function to run on the server which I may call from different client functions. The calling function will create the context for the server function. Different calling functions may send different context variables.

So the question is, how do I in code determine a context field is undefined or missing? I want to do something like: If variable is missing, do this code else do that code. Thanks…

I may have figured this out, but not sure if it was in the most efficient manner.

I added 4 buttons to my Generate Reports form: ReportAllGroups, ReportNoGroups, ReportAllPortfolios and ReportNoPortfolios. These 4 buttons were necessary, since there is no way to have action buttons on the page level, just at the top of the form. If I could do it at the page level, I’d only need 2 buttons at the top of the Groups page and 2 at the top of the Portfolios page.

The ReportAllGroups button calls a function which calls the SetIsSelectedServer function, with a context of {Table: ‘StudyGroups’, IsSelected: true}. Same for ReportNoGroups, except send false in the context.

In SetIsSelectedServer, I put the following:

    if(context.IsSelected === true || context.IsSelected === false){
      five.log(context.IsSelected);
      let sql = 'UPDATE ' + context.Table + ' SET IsSelected = ' + context.IsSelected;
      let queryResults = five.executeQuery(sql, 0);//, myKey);
    }
    
    else{
     // here I do the code for initializing the table based on the join table. this works fine.
    }

This seems to work. If context variable IsSelected is true or false it marks every group as selected or unselected, and the DataView quickly refreshes appropriately.

If IsSelected is not true or false in the context (or missing entirely), the original code works fine. It first sets StudyGroups.IsSelected to false, then updates again to true based on a SQL against the StudyGroups table with INNER JOIN to the join table.

I’m not sure how efficient this is, but it does work.
Can you suggest a more efficient way to do this, or is this method just fine?

Thanks…

1 Like

Hi Ron,

I reckon this method and your code is just fine! Big thumbs up for finding a way to make this happen!:+1:t2:

Best

Dom

I have a new issue regarding Action Buttons:

The forms in question are SetupReports and GenerateReports.
Both forms have action buttons at the top of the form. Both have All Groups, No Groups, All Portfolios and No Portfolios action buttons. These buttons run functions SetIsSelectedAllGroups, SetIsSelectedNoGroups, SetIsSelectedAllPortfolios and SetIsSelectedNoPortfolios functions respectively.

All of these functions build a context then call SetIsSelectedServer function. These functions are working just fine so far.

However, now I need to add another form page for selected members. My form already has a General page, a SelectedGroups page and a SelectedPortfolios page.

I can get this to work by adding All Members and No Members action buttons to the form, and also adding 2 more functions for when these new action buttons are clicked.

Unfortunately, there are too many buttons on the form, and the buttons will wrap into 2 rows on the form header. This is quite unwieldy.

There is a better way to solve this issue logically, but I can’t figure out how to do it. If I had my way, Five would allow action buttons on a form page, then I could add buttons for All and None at the top of each page which was a sub-form. This does not seem to be possible.

Plan B: It would work just fine, if I had All and None buttons at the top of the form, but when I click them, the function would have awareness of what form page is active. So if I click either button when the General page was active, I could have nothing happen. But if the Groups page or Portfolios page or Members page were active, I could build the context based on which was active. More importantly, I wouldn’t now need 6 buttons for the 3 form pages. This would save screen real estate and also I could get things working with only 2 extra functions, an All and a None function, which would both be aware of the active page, and do different things depending on the page.

So is this possible, knowing which form page is active when an action button is clicked?

Thanks so much for your help. I have added my latest FDF to the OneDrive folder.

UPDATE:

I have a work-around for this issue: When activating a form page, I have an event to set a SubformName variable to the action ID of that page. When leaving a page, it removes the variable. Now I have only 2 action buttons, SelectAll and SelectNone. Also only 2 functions which are called from the respective button’s click event. These functions have a switch function which, depending on the saved variable, call the server-side function with different values in the context. Also, these 2 action buttons have their showIf based on a formula which tests the “nullness” of the variable, so it doesn’t confuse the user by being visible when the General page is active.

2 questions about this:

Can I be confident that the event fired when leaving a page fires before the event fired when opening a page?

Is there a better “Five-ish” way to do this, such as a stack variable which shows inherently which form page is active? I tried to look for this using the inspector, but couldn’t find anything. Am I doing this in a correct and up-to-date manner?

Thanks…