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 / To change the status o...
Power Apps
Answered

To change the status of an item on-click and show show items based on status of user to admin

(0) ShareShare
ReportReport
Posted on by 986

Hi everyone,

I have a course screen where I am displaying list of courses (from a SharePoint list named: Course List) which is like this:

Sidhant_02_0-1683097376694.png

I have used a Horizontal Blank Gallery in which I have used a Image (common to all courses), three text labels (for title, description and Difficulty)

Sidhant_02_0-1683105015524.png

 



So currently on the Course Information screen I am displaying Title, Description, and Difficulty (this is a Choice field) the SharePoint structure look like this:

Sidhant_02_1-1683097557442.png

So now I want to add a button (which looks like Text) which is used to denote the status for the particular course which has values like Not Started, In-Progress and Complete.
Example: Assume a Tim has logged in to the application -> He navigates to the Course Information screen -> Chooses  the course category (here: Beginner) in the course list and there we have an attribute which is changes its value (like a choice column) on-selecting it (don't want to use drop down to change the value) the value should be changed on-click and saved to the sharepoint. By default the value will be Not started. I wanted something like the below picture: (Wire frame)

Sidhant_02_2-1683097949845.png

Something just like this:

Sidhant_02_0-1683104179699.png

Sidhant_02_1-1683104239643.png

 


So when user clicks on the status:
Initially it is set to Not Started (once they click it is changed to)-> In-Progress ->  Completed this should be the sequence when user clicks and this should be saved in SharePoint list (for which I was thinking of creating a Choice column named: Status with values 'Not Started', In-Progress, Completed)
So what modifications should I do to get this functionality?.

The other requirement was when a user with Admin role logs in there will some change in the Course List page. Instead of having a drop-down which shows Difficulty (Choice column) values like Beginner, Intermediate, Advanced. I want to show all the list of users and on selecting a particular user the Administrator should be able to see all the Course information for that user.

Example: Assume Tim has 2 courses which he has started one from Beginner and one from Advanced (difficulty), so if admin selects Tim from the users drop-down then they (user with Role: Administrator) should see all the courses along with the status for that particular user, in this example it should the status of one course from Beginner: difficulty as Status: In-progress and one course from Advanced Status: In-Progress and rest of the course status should be Not Started


The wireframe:

Sidhant_02_0-1683201302730.png

So I have a created a button (which looks like text) and added a label beside it which displays the Choice column value (have added Status which is a choice column with default value as Not-Started) but not sure how to update the value on the go when the button is clicked

Sidhant_02_1-1683201407195.png

 

On clicking Button16 the status column should be updated and saved in SP list and displayed in the label.

Note: I also tried removing the Choice column (Status) and added it again (Refreshed the SharePoint List) but still not able to get the Choice column in the expression

Sidhant_02_0-1683624018832.png

 

 
 
Regards, 
Sidhant.

Categories:
I have the same question (0)
  • BCLS776 Profile Picture
    8,994 Moderator on at

    To create the experience of clicking the label and having it start the course (and update accordingly), you will need to add some conditional logic to the OnSelect property of the label and perhaps the Color property too.

     

    I suggest putting a Switch() statement in the OnSelect property of the label that uses its current value to decide what next value to Patch() to the underlying datasource:

    Switch(
     ThisItem.Status.Value,
     "Not Started",
     Patch(....),
     "In-Progress",
     Patch(....),
     "Completed",
     Patch(....)
    )

    I'll warn you know about an issue I've experience with using Patch() directly on the same datasource as the gallery it is within: sometimes the gallery doesn't read the datasource correctly right after the update, so what is displayed on the gallery doesn't show the results from the Patch(). To get around this, it can be helpful to use a collection based off the datasource rather than the datasource itself in the Items property of the gallery, giving you more control over when you want the gallery to update.

    Hope that helps,

    Bryan

  • Pstork1 Profile Picture
    69,554 Most Valuable Professional on at

    Use an if() with patch statements to patch the column in SharePoint when the button is pressed.  Something like this.

    if(status.value="Not Started",patch(status: {value:"In-Progress"})if(status.value="In-Progress",patch(status: {value:"Completed"})))
  • Sidhant_02 Profile Picture
    986 on at

    Hi Bryan ,
    So you are saying to use a collection instead of the datasource directly, so in my scenario I just want to update only 1 attribute which is Status (as the user is not allowed to edit any other details, only the user with Administrator user role can do it). So in that case if I have to create a collection should I create it for one attribute or all of them, if so how to create the collection and update it and display the result?.

    I have created a collection named courseTemp, which is created on select of the button on Home screen which navigates to the Course List_2 page like:

    Sidhant_02_0-1683263749190.png

     

    Then on the Course List_2 Page (Items property)

    Sidhant_02_1-1683263790957.png

     

    So now after creating a collection how should the value of one attribute (here Status be updated on select of a button/label in the sequence which I have mentioned earlier) be updated and saved to SP list (so that for other user roles: Admin, where I want to show the datasource directly (as they will only be reading the data))

    Also the other thing, that collection only supports 500 records beyond that it can give some delegation warning so in that case will collection be a good choice?
    If possible could you just explain it in few steps.

    Sidhant_02_2-1683265267904.png

     

    (What is wrong here?)

    Sidhant_02_6-1683266275014.png

     



    Regards,
    Sidhant.

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 ,
    Was getting Status (attribute is not recognized)

    Sidhant_02_3-1683265537816.png

     


    This is my SharePoint List with the new column (Status: choice column)

    Sidhant_02_4-1683265639250.png

     

    Initially all records have Status as Blank so it should be "Not Started" on clicking the Status button/label

    Sidhant_02_5-1683265710309.png

     



    As @BCLS776 (Bryan) has mentioned in his reply that using Patch on the same data source can create some issues (gallery does not read the datasource correctly after the update), so for that he suggested to create a collection, but collection also has few limitations (which I have mentioned in the reply) so in that case is this approach a good option or is there any other option which display the results in immediately after the update is been done?
    Also if the value is blank initially then will the condition be:
    If (Status.Value = "", Patch(Status:{Value: "Not Started"}))

    Regards,
    Sidhant

  • Pstork1 Profile Picture
    69,554 Most Valuable Professional on at

    Check the URL of the Status column in the Column settings and look at the end of the address.  That will tell you what the internal name of the Status column is. Status.value should be recognizable if Status is the internal name of the column.

     

    There is nothing wrong with using Patch on the data source while using a gallery.  You just need to add a refresh(<<name of data source>>) after you do the patch to make sure it picks up the changes. That's definitely better than using a local collection.

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 and @BCLS776  ,
    First, I did try to check the URL simply by selecting the Edit Column option but did not get anything specific 

    Sidhant_02_0-1683525126256.png

    It was common for all other columns as well. So then I choose Settings -> List Settings -> Choose the Choice column (Status) and then got this:

    Sidhant_02_1-1683525203910.png

    In this the Field name was set to Status so I tried using the If statement (which you gave earlier but it still said Status is not recognized)

    Sidhant_02_2-1683525265578.png

    Also, could you let me know where the refresh should be added in the expression.
    And the particular logged in user should see their respective changes (for other users the changes made by one user should be not visible or shown. Like User 1 makes a change for Beginner course from Status: "" (blank to In-Progress then User 2 should not see the same change for Beginner Course instead it show the default values or the changes saved by User-2 ; And this should be done based on the Login credentials and not using MS Office 365 connector. Here I am using a SharePoint list named "App users" which stores the username and password. So based on that the changes made to the course list should be shown to user, which will be different for every user)

    If @HenWang (as you have helped me before with this), could you please have a look at this as well.


    Regards,
    Sidhant.

  • Sidhant_02 Profile Picture
    986 on at

    Hi @BCLS776 ,
    As @Pstork1 suggested I did check the URL for the Status choice column in the SharePoint and it was the same that I was using but still it is giving me the error that the choice column name is not recognized

    Sidhant_02_3-1683528782133.png

    So could you please let me know how to resolve this?

    Regards,
    Sidhant.

  • Sidhant_02 Profile Picture
    986 on at

    Also the other thing was the Status should be changed based for particular logged in user only.
    So for example: 
    If my app has 3 users: Sam (Role: employee), Tim (Role: employee) and Jim (Role: Administrator)
    If Sam makes a status change for one of the course (Beginner course : Staus is changed to Completed) then those changes should be only for Sam and not for other users (like Tim) i.e. for other users there should not be any change (like for Tim he should see the status as default value or if he has made any change to it then that should be visible).
    So I was trying to do this:

    Sidhant_02_4-1683530452167.png

    But this might change the Status attribute for all users (like if Sam makes a change then other users will see the same status, which should not happen)
    So in this case how to maintain isolation between users and the status attribute @Pstork1 and @BCLS776 

    Regards,
    Sidhant

  • Sidhant_02 Profile Picture
    986 on at

    I am only able to see one option for Status which is:

    Sidhant_02_0-1683613792996.png

    So I have checked the URL in my sharepoint list which has the same name (mentioned in my reply)
    So how to set the value for a particular user which means:
    (Sorry if I am repeating it again):
    There are 3 users in the application :
    User - 1: Updates the status for 1 course in Beginner to Completed then only this user should see the status as 'Completed' and not other users
    User -2 : When he/she logins in and check the Course screen the status for the Beginner Course should be the default value (or blank in my case as its not set)
    This categorization should be done based on the logged in user details (based on the user logged in)
    @Pstork1 , @BCLS776 (Bryan) do check and let me know.

    Regards,
    Sidhant

  • Sidhant_02 Profile Picture
    986 on at

    Hi @BCLS776 ,
    I did try to use the switch statement but was not sure on the Patch function so I came up with this

    Sidhant_02_1-1683617366475.png

    Currently my start value will be blank so could you share the Patch function what should be the syntax for it and the sequence of status will be ""(Blank)-> 1st click: Not Started -> (2nd click) In-Progress -> (3rd click) Completed

    Sidhant_02_2-1683617484908.png

    Please let me know.


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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard