質問

Is it possible to set this with REST (or JSOM?)

(these are not exposed as properties in List REST endpoint: MSDN List)

I can set this:

with PowerShell:

$spList.ReadSecurity=2 # 1=read all items, 2=read items created by user
$spList.WriteSecurity=4 # 1=Create and edit All, 2=Create and edit Own items, 4=None
役に立ちましたか?

解決

It is possible to set or update ReadSecurity or WriteSecurity using REST API and JSOM both.

REST API

Request body

{
  "__metadata": {
    "type": "SP.List"
  },
  "ReadSecurity": 2,
  "WriteSecurity": 4
}

End-point

/_api/web/lists/getbytitle('{List Name}')

You need to make an UPDATE request to above end-point with above request body. I have tested it using My SP REST Client.

enter image description here

More about ReadSecurity & WriteSecurity

ReadSecurity & WriteSecurity do not appear in response when you make a GET request to the list end-point but it returns all properties those are mentioned in MSDN. I mean following end-point

/_api/web/lists/getbytitle('{List Name}')

But if use $select operator in your query, then you will get the value of ReadSecurity & WriteSecurity. I mean following

/_api/web/lists/getbytitle('{List Name}')?$select=ReadSecurity,WriteSecurity

The reason is: these (ReadSecurity & WriteSecurity) properties are not returned with the resource. See more on Getting properties that aren't returned with the resource.

JSOM

Set value using

yourList.set_readSecurity(2)
yourList.set_writeSecurity(4)

Get value using

yourList.get_readSecurity()
yourList.get_writeSecurity()

他のヒント

While the OP asks specifically for a REST or JSOM approach, there is another JavaScript option (which wraps the REST API anyway) using PNPJS and is compatible with SP Online. Adding this answer for completeness.

await sp.web.lists.getByTitle("My List").update({ ReadSecurity: 2, WriteSecurity: 2 } as IListInfo); //Sets to only allow users to set and read their own list items.
ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top