web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Activate calculation i...
Power Apps
Unanswered

Activate calculation in Button external to gallery row

(1) ShareShare
ReportReport
Posted on by 8

Can anyone help with this?

I have a gallery which updates a form.
When a line in the gallery is saved, a new, line is created, and the form updates.
When the user is done, they submit the saved gallery items, and the totals to two different SharePoint lists.

The Save button only becomes active when the inputs are valid.

ToSave.pngSaved.png
I want the Submit button to be inactive if the user has forgotten to save the new line, or for a Notify message to pop up if the hit submit before saving.  
This should be easy but it seems impossible. 
It has something to do with the connection between the gallery and the button.
The best example is if I set it up so that the Submit button is only activated when the new line = zero, or when a variable says it should be inactive, but that wont take effect until i manually click on the gallery itself.

Can anyone advise of a workaround? 
The best i have come up with is to have everything dead except a little recycle sign next to the save button that god green when the save button is inactive. The lures the user to click, and in doing so they active the submit button.
Clearly this is sub optimal 🙈

The submit button must check the conditions and become active before the gallery becomes inactive and needs woken up with a click..... maybe?

Many thanks in advance.

 

Categories:
I have the same question (0)
  • Selvarokith_B Profile Picture
    82 on at

    This situation can be managed by combining the use of variables and conditions that dynamically check if the necessary criteria are met before enabling the Submit button. Below, I will describe a method to accomplish this, including how to enable/disable the Submit button based on the Save status of the current line in the Gallery and provide a Notification if the user tries to submit without saving the current line.

    1. Managing Save Status in the Gallery:
    Ensure that each line/item in the Gallery has a property or flag to indicate if it has been saved. This can be managed using a boolean variable for simplicity.

    2. Update This Variable on Save:
    When a user saves the current line, update the variable associated with that line to indicate it is saved. Use the `OnSave` property of the Save button to set this flag.

    3. Check If All Necessary Conditions Are Met:
    Use the `Submit` button's `DisplayMode` property to dynamically enable or disable the button based on the saving status of the lines in the Gallery.

    Here is an example of how you can set this up:

     

    Step 1: Add a SaveStatus Flag to Each Item in the Gallery

    Suppose your Gallery Items are collected in a collection named `colGalleryItems`. You can initialize a flag called `SaveStatus` when adding new items to this collection.

    ```plaintext
    // Add new items with SaveStatus as false initially
    Collect(colGalleryItems, { Field1: "", Field2: "", SaveStatus: false });
    ```

    **Step 2: Update SaveStatus on Save Button Click

    Set the `OnSelect` property of the Save button to update the `SaveStatus` flag of the current item.

    ```plaintext
    UpdateIf(colGalleryItems, ThisItem.ID = ID, { SaveStatus: true });
    // Additional logic for saving the data if required
    ```

    **Step 3: Enable/Disable Submit Button Based on Save Status**

    Check the `SaveStatus` of all items in the collection, and enable/disable the Submit button accordingly.

    ```plaintext
    // This function checks if all items have SaveStatus as true
    IsAllItemsSaved(colGalleryItems) ::= All(colGalleryItems, SaveStatus);

    // Use this function in the DisplayMode property of the Submit button
    SubmitButton.DisplayMode ::= If(IsAllItemsSaved(colGalleryItems), DisplayMode.Edit, DisplayMode.Disabled);
    ```

    Step 4: Notify User to Save First Before Submit

    You might want to provide feedback in case the user tries to click the Submit button when it's not enabled. You can add this logic in the `OnSelect` property of the Submit button as follows:

    ```plaintext
    SubmitButton.OnSelect ::=
    If(
    IsAllItemsSaved(colGalleryItems),
    // Submit logic here
    SubmitForm(YourForm),
    Notify("Please save all changes before submitting.", NotificationType.Error)
    );
    ```

    ### Example Code Combining All Steps in PowerApps

    Here’s a more summarized flow:

    ```plaintext
    // Initialization when adding new items
    Collect(colGalleryItems, { Field1: "", Field2: "", SaveStatus: false });

    // OnSelect of Save button
    SaveButton.OnSelect ::=
    UpdateIf(colGalleryItems, ThisItem.ID = ID, { SaveStatus: true });

    // Submit button properties
    SubmitButton.DisplayMode ::= If(All(colGalleryItems, SaveStatus), DisplayMode.Edit, DisplayMode.Disabled);

    SubmitButton.OnSelect ::=
    If(
    All(colGalleryItems, SaveStatus),
    SubmitForm(YourForm),
    Notify("Please save all changes before submitting.", NotificationType.Error)
    );
    ```

    By implementing these steps, you ensure that the Submit button is interactive only when all conditions are favorable, and you can guide the user with notifications when they attempt to submit without saving necessary changes.

     

    If you had further queries reply or Accept as solution.

    Thanks!

  • D-Coi Profile Picture
    8 on at

    Thanks for your reply, but that approach does not work. I got a simpler similar answer from CHatGPT, but it doesn't work.

  • D-Coi Profile Picture
    8 on at

    Managed to resolve this by adding the following to the save button code:

    // Navigate to the last row
    UpdateContext({varSelectedID: Last(myCollection).ID});

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard