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.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Most Valuable Professional
Most Valuable Professional

Use this check

If(
   IsBlank(ThisItem.Stage.Value),
      Patch(TrialList, ThisItem, {Stage:{Value: "In-Progress"}}),
      If(ThisItem.Stage.Value="In-Progress",
          Patch(TrialList, ThisItem, {Stage:{Value: "In-Progress"}}),
          false)
)

IsEmpty checks an object and IsBlank checks a string.  Your check should be IsBlank(thisItem.stage.value) .

Then check thisitem.stage.value="In-Progress". There is no reason to use the square brackets or First.



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

View solution in original post

What @Pstork1  has provided you in the last response works, you do need to change the last patch to Completed however like this.

 

 

 

 

 

If(
   IsBlank(ThisItem.Stage.Value),
      Patch(TrialList, ThisItem, {Stage:{Value: "In-Progress"}}),
      If(ThisItem.Stage.Value="In-Progress",
          Patch(TrialList, ThisItem, {Stage:{Value: "In-Progress"}}),
          false)
)

 

 

 

 

 


The first one I sent you worked as well, except for multi-choice columns where select multiple options was turned on, that's my mistake I should have asked how you had yours set up. Here is a video showing Pstorks code in action so you know it works.

 

https://www.dropbox.com/s/o275qnlbtf0wyc4/Untitled%20video%20-%20Made%20with%20Clipchamp%20%281%29.m...

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

View solution in original post

41 REPLIES 41
BCLS776
Super User
Super User

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

_________________________________________________________________________________________
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

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"})))


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

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.

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
Most Valuable Professional
Most Valuable Professional

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.



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

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.

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.

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

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

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

Users online (741)