Skip to content

Commit

Permalink
Merge pull request #3140 from juliemturner/version-4
Browse files Browse the repository at this point in the history
Documentation Updates
  • Loading branch information
patrick-rodgers authored Sep 24, 2024
2 parents a285f55 + e681172 commit 39cf2ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
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

0 comments on commit 39cf2ec

Please sign in to comment.