Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Updates #3140

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/sp/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ const folder: IFolder = await sp.web.rootFolder.folders.getByUrl("SiteAssets").a

### getFolderById

You can get a folder by Id from a web.
You can get a folder by UniqueId from a web.

```TypeScript
import { spfi } from "@pnp/sp";
Expand All @@ -542,7 +542,8 @@ import { IFolder } from "@pnp/sp/folders";

const sp = spfi(...);

const folder: IFolder = sp.web.getFolderById("2b281c7b-ece9-4b76-82f9-f5cf5e152ba0");
const folderItem = sp.web.lists.getByTitle("My List").items.getById(1).select("UniqueId")()
const folder: IFolder = sp.web.getFolderById(folderItem.UniqueId);
```

### getParentInfos
Expand Down
36 changes: 34 additions & 2 deletions docs/sp/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,13 @@ await execute();

console.log("Done");
```

### Update Taxonomy field

Note: Updating Taxonomy field for a File item should be handled differently. Instead of using update(), use validateUpdateListItem(). Please see below

List Item
#### List Item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
Expand All @@ -385,7 +387,9 @@ await sp.web.lists.getByTitle("Demo").items.getById(1).update({
});

```
File List Item

#### File List Item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
Expand All @@ -407,6 +411,8 @@ _Based on [this excellent article](https://www.aerieconsulting.com/blog/update-u

As he says you must update a hidden field to get this to work via REST. My meta data field accepting multiple values is called "MultiMetaData".

#### List Item

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
Expand All @@ -433,7 +439,9 @@ await sp.web.lists.getByTitle("TestList").items.getById(newItem.Id).update(updat
```

#### File List Item

To update a multi-value taxonomy field on a file item, a different serialization is needed.

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
Expand Down Expand Up @@ -482,6 +490,30 @@ const update = await sp.web.lists.getByTitle("Price").items.getById(7).select('*
]);
```

### Update Location Field

This code shows how to update a location field's coordinates.

```TypeScript
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const sp = spfi(...);
const coordinates = {
Latitude: 47.672082,
Longitude: -122.1409983
}

const projectId = 1;
const project = sp.web.lists.getByTitle("My List").items.getById(projectId).select("Id, ProjectLocation")()
const projectLocation = JSON.parse(project.ProjectLocation);
projectLocation.Coordinates = coordinates;
const ProjectLocation = JSON.stringify(projectLocation);
const update = await sp.web.lists.getByTitle("My List").items.getById(projectId).update({ ProjectLocation });
```

## Recycle

To send an item to the recycle bin use recycle.
Expand Down