SharePoint / SharePoint/sp-dev-docs

Correct way of saving data to a page column from SPFx webpart while page is in edit mode

Open
#10,131 8 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

sharepoint-developer-support status:by-design
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details
  • browser version: all
  • SPFx version: newest
Issue description

I am looking for a way to store data that a user enters into a SPFx web part while the page is in edit mode in a page column. A column because I want to query the data via search.

The process would be as follows:

  • User edits the page
  • Adds the WebPart
  • Enters data into the web part
  • Saves the page
  • Data is saved in a column

I am aware that the data from a web part is saved in web part properties and that these properties can be made searchable. I can then also find results via the search. However, the data can only be found in the managed property “SPFxExtensionJson”, hidden in HTML and JSON. This is not a nice way to work with the data.

The APIs “ValidateUpdateListItem” and “/_api/sitepages/SavePage” are also known to me, but no longer really work in the new “collaboration mode”. Before this new mode, I could save data in the column via “ValidateUpdateListItem”, but this is overwritten as soon as the page is saved via the interface.

What I am looking for would be an API in the web part itself, for example a function like “onPageSave(oldValue, newValue)” which is executed as soon as the user saves the page via UI and as a web part developer you can still influence what is saved and insert data.

Or is there an other way to edit the list item of the page while the user is in edit mode?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.