To disable the submit button in your Power Apps canvas app based on specific conditions in a connected SharePoint list, you will need to follow these steps. This process involves fetching the SharePoint list item based on the author email and checking the value of the "active" column. Here's how you can accomplish this:
- Ensure Your SharePoint List Connection: First, make sure you have added your SharePoint list as a data source in your Power Apps canvas app.
- Use the LookUp Function: You can use the LookUp function to search the SharePoint list for an item that matches the author's email and where the "active" column is set to true.
- Disable the Submit Button: Set the button's DisplayMode property to conditionally disable it based on the result of the LookUp function.
Here is a step-by-step guide:
Step 1: Add SharePoint List as Data Source
- In your Power Apps canvas app, go to "Data" on the left-hand side panel, click "Add data," and select your SharePoint list. Let's assume your list is named "AuthorsList" for this example.
Step 2: Write the Formula for the Button's DisplayMode Property
- Select the submit button in your app.
- In the formula bar, set the DisplayMode property of the button to something like the following:
If(
IsBlank(
LookUp(
AuthorsList,
AuthorEmail = User().Email && Active = true
)
),
DisplayMode.Edit,
DisplayMode.Disabled
)
Explanation:
- LookUp(AuthorsList, AuthorEmail = User().Email && Active = true): This part checks the "AuthorsList" for an item where the "AuthorEmail" column matches the current user's email (assuming User().Email retrieves the current user's email) and the "Active" column is true.
- IsBlank(...): This checks if the LookUp function found any item. If it returns true, it means no item was found where the author's email matches and is active, hence the condition to decide if the button should be disabled.
- DisplayMode.Edit means the button is enabled, and DisplayMode.Disabled means the button is disabled.
By using this formula, the submit button will be disabled if there's an item in the "AuthorsList" where the "AuthorEmail" matches the current user's email and the "Active" column is set to true. Otherwise, the button will be enabled.
This approach assumes that the "AuthorEmail" and "Active" are the correct internal names of your columns in SharePoint. Ensure to replace them with the actual internal names of your columns. Also, this formula uses User().Email to get the current user's email, ensure this matches how your app is set up to identify users.