-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #393 from patrick-rodgers/dev
Update to remove restriction on update object for folders, add docs p…
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# @pnp/sp/content types | ||
|
||
## Set Folder Unique Content Type Order | ||
|
||
```TypeScript | ||
interface OrderData { | ||
ContentTypeOrder: { StringValue: string }[]; | ||
UniqueContentTypeOrder?: { StringValue: string }[]; | ||
} | ||
|
||
const folder = sp.web.lists.getById("{list id guid}").rootFolder; | ||
|
||
// here you need to see if there are unique content type orders already or just the default | ||
const existingOrders = await folder.select("ContentTypeOrder", "UniqueContentTypeOrder").get<OrderData>(); | ||
|
||
const activeOrder = existingOrders.UniqueContentTypeOrder ? existingOrders.UniqueContentTypeOrder : existingOrders.ContentTypeOrder; | ||
|
||
// manipulate the order here however you want (I am just reversing the array as an example) | ||
const newOrder = activeOrder.reverse(); | ||
|
||
// update the content type order thusly: | ||
await folder.update({ | ||
UniqueContentTypeOrder: { | ||
__metadata: { type: "Collection(SP.ContentTypeId)" }, | ||
results: newOrder, | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters