cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sidhant_02
Post Prodigy
Post Prodigy

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

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.

41 REPLIES 41

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.


BCLS776
Super User
Super User

Try this syntax for the Switch() statement instead:

Switch(
    ThisItem.Status.Value,
    "Not-Started",
    Patch('Courses List', ThisItem, {Status: {Value: "In-Progress"}}),
    "In-Progress",
    // Place code here for what change you want when Status is already In-Progress, maybe a Navigate() to the appropriate course screen?
)

When working with columns in this way, make sure the Value you are patching to the Status column matches one of the choices or your Patch() may return an error. I noticed some discrepancies between the usage of "Not-Started" and "Not Started", which will lead to some frustrating behavior for the app.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Pstork1
Most Valuable Professional
Most Valuable Professional

But what do you see in intellisense if you add a period after status?  That's when you should see the name of the property. Normally its 'value'.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Going to provide you a very simple example you can use to understand how patching/editing a choice column works and then be able to apply it to your issue.

First off, PStork likely had the solution to your issue early on, but you missed it.

TheRobRush_0-1683649583885.png

 

When he told you to check the actual column name in the sharepoint list via the web address he did not mean from this page, you have to do this in list settings. So before you even start my example, get this name in the following manner so we know you are working with the right one.

Open your list and click the gear in upper right hand corner then click list settings

 

TheRobRush_1-1683649697349.png

 

Now click your column name

TheRobRush_2-1683649747325.png

 

Now look at the end of your address bar, you will see whatever is after the = is your reference column name, in my example here you will see the column name and iits reference name are different. In powerapps i would call this column title

 

TheRobRush_3-1683649843191.png

 

Now in Powerapps I have a gallery, and in there I have one control that has the text value of ThisItem.Title, and another with the TextValue of

If(
    IsEmpty(ThisItem.Area), "To Do",
    First(ThisItem.Area).Value)

this second one is my choice column

 

This control has an onselect of

If(
    IsEmpty(ThisItem.Area), 
    Patch(MainEntryVenues,ThisItem, {Area:[{Value: "In Progress"}]}),
    If(
       First(ThisItem.Area).Value="In Progress",
       Patch(MainEntryVenues,ThisItem, {Area:[{Value: "Complete"}]}
       ),
    false)
   )

 

This first checks if this Area Choice column is empty, and if it is changes the value to in progress, and later on if its in progress changes it to complete.

 

I do not generally recommend using choice columns though, as you can accomplish the same result using a single line of text column and have far more control over delegation later on. Even when you want the ability to make and store more than one choice, just use single line of text and a delimiter like ;; or something that you can break down later in powerapps

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

In Intellisense do you mean the Power Apps Web portal right?, when I used the code which you had replied (your 1st reply) the Status was not recognized at all (even after checking the actual name of the column from List Settings).

Thanks I will try this out. At present the start value is Blank so in that case how should the blank value be checked, if its blank then the status should be Not-Started. If the Status = 'In-Progress' then it should be 'Completed'.
//So if the Start value is In-Progress
Patch('Courses List', ThisItem, {Status :{Value: "Completed"}})
//Is it correct?

Regards,
Sidhant

Hi @TheRobRush ,
Thanks for the response, I will try this once, if possible you have mentioned to use a single of text instead of Choice column so could you please share on how to implement it: ("" {empty} -> Not-Started -> In-Progress -> Completed) this will be the sequence of flow.

Regards,
Sidhant.

Yah i mean in that case, using a single line of text, it becomes just a very simple patch where you 

 

 

Switch(
       ThisItem.Column,
       Blank(), Patch(ListName, ThisItem, {Column: "First Value"}),
       "First Value", Patch(ListName, ThisItem, {Column: "Second Value"}),
       Patch(ListName, ThisItem, {Column: "Third Value"})
)

//and so forth

 

 

 

You really should not use a choice column unless you have no other possible way to accomplish your needs (which I cannot really think of a situation off hand where there would be no way to avoid using one but maybe @Pstork1  has encountered one at some point.) In addition to maintaining far more delegation control it is simpler to patch.

 

As for using the column as is, just follow my guide above. IF you have a selected item to start with and that selection just has the value of "" then you can change 

 

 

IsEmpty(ThisItem.Status)

 

 

 

to Something like 

 

 

First(ThisItem.Status).Value=""

 

 

 

But if it starts off with no actual selection then you would want to check if it's empty like my example, because a choice column is just a nested table, that starts off empty.

 

 

 

If(
    IsEmpty(ThisItem.Status), /* or, First(ThisItem.Status).Value="" */
    Patch('Courses List',ThisItem, {Status:[{Value: "In-Progress"}]}),
    If(
       First(ThisItem.Status).Value="In-Progress",
       Patch('Courses List',ThisItem, {Status:[{Value: "Completed"}]} 
/* Though according to earlier screenshots this column is likely not actually called Status so you need to change this */
       ),
    false)
   )

 

 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Hi Bryan,
I did try your expression which was like this:

Switch(
ThisItem.Status.Value,
"Not-Started",
Patch('Courses List',ThisItem,{Status:{Value:"In-Progress"}}),
"In-Progress",
Patch('Courses List',ThisItem,{Status:{Value:"Completed"}})
)

Sidhant_02_0-1683697294215.png

So the expression has no errors now but when I tried testing after clicking on Status (which is a button), beside I have placed a Label to display the Status Value like this:

Sidhant_02_1-1683697413813.png

But it did not display any value after clicking on the Status button, I even checked the SharePoint List there was no change.

The other thing which I have mentioned in my last reply as well (I guess you missed it) is:
Scenario: 
Lets say I have 3 users in my application (registered) and their credentials (username and Password are stored in another list named 'App users')
Assume users are Sam, Tim, Jim (Role: Administrator)  //Sam and Tim Role: Employee
Sam logins in the application navigates to Course List screen and changes the Status for one of the Course let's say Beginner Course from blank to In-Progress. So now only Sam should see the Status of the course set to In-Progress, whereas for Tim the Status should be the default value (here it will be blank). So how to do this?
(It should not refer to MS Office 365 connector as I want to check the details from my App Users SP list to check which user has logged in)
So let me know if you know how to do this?

Regards,
Sidhant

Hi @TheRobRush ,
Thanks for the quick reply, I will try the Choice column option & the Text option too as you said it is good approach than choice. I had opted for Choice column as I did not know we can have text column with some some choice column like working.
Also if possible could you also have a look at my reply to @BCLS776 (Bryan) at the end which was each user should see their changes in isolation i.e. if one user makes a change it should not be visible to others as well rather he/she should see it.

Regards,
Sidhant.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages