SharePoint Development (List Permissions)

John-Maxwell, Samuel 0 Reputation points
2024-12-09T13:20:37.53+00:00

Hi! I'm currently working on a project, and I want to use SharePoint lists. My roadblock is that I want to ensure edits on a SharePoint list are not made after the day has passed. How can I do this? Please help.

Microsoft 365 and Office | SharePoint | Development
{count} votes

2 answers

Sort by: Most helpful
  1. John-Maxwell, Samuel 0 Reputation points
    2024-12-11T13:18:28.5566667+00:00

    Hi @Ling Zhou_MSFT .

    Question 1 (Version): SharePoint in Microsoft 365

    Question 2 (Background): I am new to Power Automate but I was thinking of utilizing HTTP just not sure how to build this flow.

    0 comments No comments

  2. Ling Zhou_MSFT 23,670 Reputation points Microsoft External Staff
    2024-12-12T07:05:35.4166667+00:00

    Hi @John-Maxwell, Samuel,

    Much appreciate for your clarification.

    According to the information you provided and the research I have done, I may understand that you need to use power automate to remove the edit permission of a user or group after one day. If there is anything wrong, please correct me.

    If there is not anything wrong, it is suggested that you please try the following steps:

    1.Create a Scheduled Flow:

    • Go to Power Automate and select Create from the left-hand menu.
    • Choose Scheduled cloud flow.

    2.Set the Recurrence:

    • In the Build a scheduled flow dialog, set the Flow name.
    • Set the Starting date and time for when you want the flow to begin.
    • Under Repeat every, set the interval to 1 and the frequency to Day.
    • Click on Show advanced options to set the time zone and specific times of day if needed.

    3.Break Inheritance (Skip this step if your list has broken permissions.):

    • Use the "Send an HTTP request to SharePoint" action to break the inheritance of permissions on the list. This step ensures that the list no longer inherits permissions from its parent site.
        Method: POST
        Site Address: https://<your-sharepoint-site>
        URI: _api/web/lists/getByTitle('<List_Title>')/breakroleinheritance(copyRoleAssignments=false, clearSubscopes=true)
      
      User's image

    4.Remove Permissions:

    • Use another "Send an HTTP request to SharePoint" action to remove specific permissions. You will need to specify the list and the user or group whose permissions you want to remove. The way to get the User_ID is shown below.
        Method: POST
        Site Address: https://<your-sharepoint-site>
        URI: _api/web/lists/getByTitle('<List_Title>')/roleassignments/removeroleassignment(principalid=<User_ID>)
      
    • Get user's USER_ID in browser.
    GET https://<your-sharepoint-site>/_api/web/siteusers/GetByEmail('userEmail')/Id
    

    User's image

    • Get group's USER_ID in browser.
    GET https://<your-sharepoint-site>/_api/web/sitegroups/getbyname('GROUP_NAME')/Id
    

    User's image

    5.Add New Permissions (Optional):

    • If you need to set new permissions, use the "Send an HTTP request to SharePoint" action again to add the desired permissions.
        Method: POST
        Site Address: https://<your-sharepoint-site>
        URI: _api/web/lists/getByTitle('<List_Title>')/roleassignments/addroleassignment(principalid=<User_ID>, roleDefId=<Role_ID>)
      
      User's image
    • Get Role_ID:
      • Here are some common Role Definition IDs:
            Full Control: 1073741829
            Design: 1073741828
            Edit: 1073741830
            Contribute: 1073741827
            Read: 1073741826
            Limited Access: 1073741825
            View Only: 1073741924
        
      • If you want to get the Role_ID of a custom permission level, you need to make the following request in the browser and use the Xml parsing tool to parse the result to get the Role_ID of your custom permission level.
            GET https://<your-sharepoint-site>/_api/web/roledefinitions
        
        User's image

    If you have any questions, please do not hesitate to contact me.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. It will be beneficial to more community members reading here. Your contribution will be highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.