Thursday, December 31, 2020

PowerApps: Conditional Display/Hide of Icons

 Hello Friends,

Welcome again with my new post on PowerApps. Today, we will learn some additional features of PowerApps which are quite useful during apps development. In this series, let start with-

  1. Conditional Display & Hide of Icons
For this, what we need is-
  1. A Scenario
  2. A SharePoint List
  3. A PowerApps App
Let's Start-
  1. Scenario:- Sometimes, we have to build an app where-
    1. User can create only one record. IF record has been created by him/her, he/she should not be able to create further any record.
    2. User should be able to edit only it's own record.
    3. In real life, we can have this scenario where an organization/team has to maintain it's all employees/team members info and all employees should be able to access that information on the fly.
  2. SharePoint List:- I have created a list for this-
  3. PowerApps App:- Also created a PowerApps app with following screens-
      1. WelcomeScreen
      2. ListScreen
      3. NewScreen
      4. EditScreen
      5. ViewScreen
  4. Process:

    1. On ListScreen, the "+" icon works to add new record. We will add condition on it.
    2. We will change the "Visible" property as below-
    3. If(CountRows(Filter(galleryTeamList.AllItems, EmailID = User().Email))<1, true,false)
      

    4. We are verifying if there is any record in gallery with EmailID matching with that of current logged-in user where EmailID is the column of our list and storing the current user Email ID.
    5. This way user can only one record for itself.
    6. This completes first part of Scenario. Now coming to second scenario.
    7. For this, we will add an Edit icon in gallery.

    8. Let's add below code for the "Visible" property of this icon.
    9. If(User().Email = ThisItem.EmailID, true, false)

    10. I had added two records using different accounts. it is clearly shown in above screenshot, edit icon is visible for one record, while for other, it is hidden.
    11. Now the question may arise that while inserting first record, user can input wrong email id. We had a solution for this also. We had disabled the DataCard of EmailID and set it's Default property to- User().Email

    12.  This way user cannot be able to change his/her email id.
Happy Coding...
Will see you again with some new topics.

Bye... Bye... 2020
Wishing All Readers & Coders . . .        !!! A Very Happy New Year !!!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.