cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PJBruen
Resolver I
Resolver I

Opening a Sharepoint Document in Read-Only Mode

Hi, 

I have a PowerApp whereby a case is created and a document is saved to the Sharepoint Document Library and referenced by the case. Whilst the document goes through various stages of approval, it can be viewed and edited by clicking a link to it using the command Launch(First(colSelectedDocuments).'Link to item'). This all works fine!

 

However, what I would like to be able to do, is when the document has been fully approved, is there a way to change the link so that the document only opens in Read-Only mode?

 

I've since tried building this in Power Automate, but I get stuck on the first HTTP request;

https://sergeluca.wordpress.com/2018/05/03/assign-unique-permissions-to-a-document-with-the-new-send...

 

The error I get is:

The expression "lists/getByTitle(‘Documents’)/items(1)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)" is not valid.
clientRequestId: cb961482-17a5-4d40-ae78-893386123126
serviceRequestId: 820a939f-c0ee-2000-70ec-a673bfc63c7a

 

(I've tried changing the Items parameter to the ID of a document in the list...still no luck.  /items(1)/

Many thanks

Paul

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Most Valuable Professional
Most Valuable Professional

Use the names in the Advanced Permissions Settings.  That will be the name which the group ID can be retrieved with.  If you use another name it will keep retrying for about 10 minutes since it can't find a match. That may be why your first attempt didn't finish.



-------------------------------------------------------------------------
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

21 REPLIES 21
Pstork1
Most Valuable Professional
Most Valuable Professional

There is no way to change the formatting of the link to make it read only.  To do that you have to actually change the item level permissions on the document itself in SharePoint.  That can be done using an HTTP REST call. Or you can try these actions on sharing.

 

Manage list item and file permissions with Power Automate | Microsoft Docs



-------------------------------------------------------------------------
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 , yeah, that's what the link above is trying to do (unless I've misunderstood).

I get an error with the first HTTP request....not sure what I'm doing wrong.

 

Regards.

Pstork1
Most Valuable Professional
Most Valuable Professional

Take a look at this example.  I think it does a better job of explaining which dynamic content to use in the requests.  

How to manage permissions on a SharePoint List Item using Microsoft Flow – changing Item permissions...



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

@Pstork1 

Hi,

I'm trying to follow some instructions put together by @BenFetters at:  

https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Power-Automate-and-SharePoint-Perm...

Ben, I wonder if you are able to assist me here with a Power Automate/Sharepoint question??

What I'm trying to do is call a Power Automate flow from PowerApps that needs to set a specific document in the Document Library to Read Only. The document should still appear in the library, but ideally only editable by "Owners" and only viewable by "Members".

I've attached some screen shots of Sharepoint and the flow I have so far.

This appears to work, but obviously only changes the permissions for the one user, detailed in the "Send an HTTP request to Sharepoint 2" action.

Are you able to advise what I need to do to this flow to make it set the document to Read Only for everyone in the "Member" group? I'm a bit confused as to how to do this!

 
 

Sharepoint1.png

Sharepoint2.png

PowerAutomate1.png

PowerAutomate2.png

 

Many thanks

Paul.

Pstork1
Most Valuable Professional
Most Valuable Professional

The problem is in the last two http calls.  In one you are retrieving a principal ID by email.  But you need to get the group id not the user's ID.  That requires a different call.  Then feed that id in as the principal id.  Here is a working example.

image.png



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

Thanks @Pstork1 

I did change my flow to look at the group, but it never completed and therefore I cancelled it as I wasn't sure I had it right.

Before I change it again and test it, should URI field be changed to "Member" (as per the group names on the first screenshot) or should I use the names in the Advanced Permission Settings? 

 

PJBruen_0-1606923765341.png

 

Pstork1
Most Valuable Professional
Most Valuable Professional

Use the names in the Advanced Permissions Settings.  That will be the name which the group ID can be retrieved with.  If you use another name it will keep retrying for about 10 minutes since it can't find a match. That may be why your first attempt didn't finish.



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

Many thanks for your help @Pstork1 - that seems to work exactly as I need it too.

PJBruen
Resolver I
Resolver I

@Pstork1 

Hi - I've been doing some more testing on this application. The manage access process below was working absolutely fine yesterday, but today, only the side of the flow for making a file editable (1073741830) is working. There are no errors....it just doesn't change the access level to Read Only (1073741826), when following the path where the condition is set to "LOCK".

Any ideas why?

PJBruen_0-1607092423787.png

 

Cheers - Paul

Pstork1
Most Valuable Professional
Most Valuable Professional

I assume you are trying to use this like a Toggle.  The problem is that it isn't designed to work that way.  The permissions are assigned to the group by the command.  But assigning the Read Permission doesn't remove the existing Edit permission.  It works the first time through because it removes all permissions except yours when you break inheritance.  But after that each time you run the HTTP command it adds the permission level back in.  So to set ReadOnly its a Two step process.  First you have to remove the Edit permission (if it exists) and then add the Read permission.  You should be able to remove a permission level setting using the following

 

_api/web/lists/getByTitle('List%20Name')/Items('ItemID')/RoleAssignments/groups/RemoveByLoginName('GroupName')

 

 



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

Hi @Pstork1 

Ahh, I see.

I've tried the following, but unfortunately I get errors on this step. As you've kindly got me this far, would you know how I get around this? You're correct though, the Edit Mode vs. Read-Only Mode needs to work slightly like a toggle I guess. It's likely that when the file gets set to read-Only that it stays that way, but there needs to be the facility to undo it, and make the file editable again.

PJBruen_0-1607331235333.png

BODY

{
  "status"400,
  "message""This operation is not allowed on an object that inherits permissions.\r\nclientRequestId: 5bac034d-7ce6-4565-ac20-2cd5cb0fc12f\r\nserviceRequestId: 54e8949f-5059-2000-70ec-a6836e6895d0",
  "errors": [
    "-1",
    "System.InvalidOperationException"
  ]
}
HEADERS
{
  "Pragma""no-cache",
  "x-ms-request-id""54e8949f-5059-2000-70ec-a6836e6895d0",
  "Strict-Transport-Security""max-age=31536000; includeSubDomains",
  "X-Content-Type-Options""nosniff",
  "X-Frame-Options""DENY",
  "Cache-Control""no-store, no-cache",
  "Set-Cookie""ARRAffinity=9b2d45c4bd0030f30e7a2a2896b71140eb7d88b49b44e96d4fd45755b575263c;Path=/;HttpOnly;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net,ARRAffinitySameSite=9b2d45c4bd0030f30e7a2a2896b71140eb7d88b49b44e96d4fd45755b575263c;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net",
  "Timing-Allow-Origin""*",
  "x-ms-apihub-cached-response""true",
  "Date""Mon, 07 Dec 2020 08:36:36 GMT",
  "Content-Length""491",
  "Content-Type""application/json",
  "Expires""-1"
}
 
Many thanks,
Paul.
Pstork1
Most Valuable Professional
Most Valuable Professional

The error suggests that you are trying to do those steps without breaking security inheritance first.  Any time you are going to set specific permissions you have to be sure that inheritance is turned off.



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

Hi @Pstork1 

Is that not the purpose of this step though, which is running in my flow.....or am I missing something else?

PJBruen_0-1607348919942.png

Sorry to keep hassling you. This is the first time I've ever looked at this stuff, and it's a bit foreign to me, so your help is much appreciated.

 

Regards,

Paul

Pstork1
Most Valuable Professional
Most Valuable Professional

OK, I see the error.  In the first of the two statements that removes the permissions you are doing it at the list level not the item level.  Everything up through role assignments should be the same on both commands.  in your example you are trying to remove permissions from the list and set them on the item.  Both of those need to be at the item level.



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

Hi @Pstork1 

So, these are the 4 HTTP Send Requests I'm making. I've made one change in red, but wasn't sure what to change in the other (sorry, so confused by this). Can you confirm please?

_api/lists/getByTitle('varLISTNAME')/items(varID)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)

_api/web/SiteGroups/getbyname('varPERMISSIONGROUP')

_api/web/lists/getByTitle('varLISTNAME')/items(varID)/RoleAssignments/groups/RemoveByLoginName('varPERMISSIONGROUP')

_api/lists/getByTitle('varLISTNAME')/items(varID)/roleassignments/addroleassignment(principalid='varGroupID',roledefid=1073741826)

Pstork1
Most Valuable Professional
Most Valuable Professional

The change in red is the correct change.  Everything should work if its setup that way.



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

Hi @Pstork1 

Sorry - I still haven't got this quite right.

PJBruen_0-1607423670973.png

This is the URI being entered here:

 _api/web/lists/getByTitle('Documents')/items(11441)/RoleAssignments/groups/RemoveByLoginName('Stress Testing Datastore Members')

 

The error coming back as Bad Gateway (although the flow was still running, but cancelled after a few mins):

PJBruen_1-1607423783508.png

 

Is "RemoveByLoginName" correct as this is the Group name as opposed to an individual?

 

Sorry again to keep hassling you.

 

Regards

Paul 

 

PJBruen
Resolver I
Resolver I

@Pstork1 

So, I tried the following:

If I create a new Sharepoint File and run the READ-ONLY process, then the flow errors with the details above.

If I create a new Sharepoint File and run the EDIT process and then the READ-ONLY process, it seems to work fine.

 

Would this be what you'd expect?

I don't fully understand this, but as long as it works I'm happy I think!

 

  

Pstork1
Most Valuable Professional
Most Valuable Professional

Yes, Remove ByLoginName is the right syntax.  But you will get a Bad Gateway error if the Group doesn't have permissions.  If this is the first time through after breaking security inheritance than the group won't have permissions and you will get an error.  But it should work if the group has read permissions because this is the second time adjusting permissions.



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

Helpful resources

Announcements

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!    

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Users online (5,582)