You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/extensions/get-started/building-form-customizer.md
+202-4Lines changed: 202 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Build your first Form customizer extension (preview)
2
+
title: Build your first Form customizer extension)
3
3
description: Form customizers are SharePoint Framework components giving you an option to override the form experience in a list or library level by associating the component to the used content type.
Form customizers are SharePoint Framework components giving you an option to override the form experience in a list or library level by associating the component to the used content type. Form customizer components can be used in SharePoint Online, and you build them using modern JavaScript tools and libraries.
12
12
13
13
>[!Important]
14
-
> Form customizer will be released as part of the SharePoint Framework 1.15 which is currently still in preview status. See [v1.15 release notes](../../release-1.15.md) for details.
14
+
> Form customizer were released as part of the SharePoint Framework 1.15, so ensure that you are using the right version in your environment. See [v1.15 release notes](../../release-1.15.md) for details.
15
15
16
16
## Create an extension project
17
17
@@ -175,7 +175,205 @@ You can test and debug your Form Customizer within a live SharePoint Online site
175
175

176
176
177
177
178
-
That's it. You have now created your first custom form component.
178
+
## Add form item editing capabilities to the sample
179
+
180
+
Now that we have created the baseline component and tested that it works properly. We will be creating a separate rendering logic for display, edit and new forms and to support saving new items to the list.
181
+
182
+
1. Open the **./src/extensions/helloWorld/loc/myStrings.d.ts** file, and add new **Title** to the **IHelloWorldFormCustomizerStrings** interface . Interface should be as follows after your edits..
1. Open the **./src/extensions/helloWorld/loc/en-us.js** file, and add new **Title** string to the file. File content should be as follows after your edits.
194
+
195
+
```typescript
196
+
define([], function() {
197
+
return {
198
+
"Save": "Save",
199
+
"Cancel": "Cancel",
200
+
"Close": "Close",
201
+
"Title": "Title"
202
+
}
203
+
});
204
+
```
205
+
206
+
1. Open the **./src/extensions/helloWorld/HelloWorldFormCustomizer.module.scss** file, and update the styling definition as follows. We are adding error styling for the component.
1. Move to the top of the **HelloWorldFormCustomizer.ts** file.
221
+
1. Locate the line `import styles from './HelloWorldFormCustomizer.module.scss';` and add the following lines immediately after it:
222
+
223
+
```typescript
224
+
import { FormDisplayMode } from '@microsoft/sp-core-library';
225
+
import {
226
+
SPHttpClient,
227
+
SPHttpClientResponse
228
+
} from '@microsoft/sp-http';
229
+
```
230
+
231
+
1. Include **_item** and **_etag** private types inside of the **HelloWorldFormCustomizer** class as shown in this code snippet. Notice that the class definition already exists in your code.
// Added for the item to show in the form; use with edit and view form
239
+
private _item: {
240
+
Title?: string;
241
+
};
242
+
// Added for item's etag to ensure integrity of the update; used with edit form
243
+
private _etag?: string;
244
+
```
245
+
246
+
1. Update the **onInit()** method as follows. This code is using **this.displayMode** to determine the status of the rendering and then fetches the selected list item if that's needed.
// store etag in case we'll need to update the item
265
+
this._etag = res.headers.get('ETag');
266
+
return res.json();
267
+
}
268
+
else {
269
+
return Promise.reject(res.statusText);
270
+
}
271
+
})
272
+
.then(item => {
273
+
this._item = item;
274
+
return Promise.resolve();
275
+
});
276
+
}
277
+
```
278
+
279
+
1. Update the **render()** method as follows. Render the form either in display only or in the edit mode, depending on the display mode of the form. In this case we use the same renderig for new and edit experience, but you could easily have dedicated option if needed.
280
+
281
+
```typescript
282
+
public render(): void {
283
+
// render view form
284
+
if (this.displayMode === FormDisplayMode.Display) {
this.domElement.querySelector(`.${styles.error}`).innerHTML = `An error has occurred while saving the item. Please try again. Error: ${error.error.message}`;
1. Add new method **_updateItem** to the **HelloWorldFormCustomizer** class.
371
+
372
+
```typescript
373
+
374
+
```
375
+
376
+
Now the code is complete to support minimal New, Edit and Display experiences and you can test out the different experiences using different configurations for debugging.
There will be multiple public preview release using the @next tag in the NPMJS.org registry before final release candidates and a final public release.
10
+
This release introduces updates across the features around Microsoft Viva, Microsoft Teams and SharePoint.
The Form Customizer Extension allows developers to customize new, edit and display forms of the lists and document libraries.
45
+
The Form Customizer Extension allows developers to customize new, edit and display forms of the lists and document libraries.
50
46
51
47
* [Tutorial on creating your first form customizer](extensions/get-started/building-form-customizer.md)
52
48
53
49
> [!NOTE]
54
-
> The API to apply form customizers to a content type or list is still work in progress.
55
-
> Developers can use local debugging and direct link to `SPListForm.aspx` page to test the customizers.
56
-
> Please, check `config\serve.json` file created during the provisioning for more details.
57
-
> You can see live demo of this process from following YouTube video - [Preview on upcoming list extensibility options with SPFx v1.15](https://www.youtube.com/watch?v=90DWB9hjo-k).
50
+
> You can see live demo of this feature from the following YouTube video - [Getting started on building custom list form components with SPFx v1.15](https://www.youtube.com/watch?v=LF5eQHBx10o).
51
+
52
+
53
+
### Node.js v16 Support
54
+
55
+
SharePoint Framework solutions now support Node.js v16 as the default Node.js version.
56
+
58
57
59
58
### Microsoft Graph JavaScript SDK v3 Support
60
59
61
60
The **MSGraphClientFactory** allows a developer to select the version of the Microsoft Graph JavaScript SDK to use.
62
61
63
62
> [!NOTE]
64
-
> Default behavior is to use v1 of the Microsoft Graph JavaScript SDK forbackward compatibility.
63
+
> Starting with SPFx 1.15 only v3 of the Microsoft Graph JavaScript SDK is supported. v1 support is removed forall new and updated solutions. Please update your code accordingly to get the right version.
65
64
66
65
```typescript
67
66
this.context.msGraphClientFactory.getClient('3');
68
67
```
69
68
70
69
### TypeScript v4 Support
71
70
72
-
SPFx solutions now support TypeScript v4.5
71
+
SharePoint Framework solutions now support TypeScript v4.5
73
72
74
73
### ESLint Support
75
74
76
-
SPFx solutions now support ESLint 8.3.0 instead of deprecated TSLint.
75
+
SPFx solutions now support [ESLint](https://github.com/typescript-eslint/typescript-eslint) 8.x instead of the deprecated [TSLint](https://github.com/palantir/tslint).
77
76
78
77
### Updated Microsoft Teams JavaScript Client SDK
79
78
80
-
SPFx solutions now support Microsoft Teams JavaScript Client SDK v1.12.1.
79
+
SharePoint Framework solutions now support [Microsoft Teams JavaScript Client SDK v1.12.1](https://github.com/OfficeDev/microsoft-teams-library-js).
81
80
82
81
### Updated Command Set Extension Template
83
82
84
83
The template was updated to use `listViewStateChanged` event instead of deprecated `onListViewUpdated` event.
85
84
86
85
### Changes to Scaffolding Options and Prompts
87
86
88
-
- new command line option: `--use-heft`. If specified, the solution will build the project using Heft.
87
+
- new command line option: `--use-heft`. If specified, the solution will build the project using [Heft](https://rushstack.io/pages/heft/overview/).
89
88
90
89
## Deprecations
91
90
@@ -95,19 +94,22 @@ The template was updated to use `listViewStateChanged` event instead of deprecat
95
94
96
95
### February & March Timeframe
97
96
98
-
-[#7827](https://github.com/SharePoint/sp-dev-docs/issues/7827) - `deploy-azure-storage` command always creates container with Pubic Access Level of 'Private' instead of Blob
99
-
-[#7826](https://github.com/SharePoint/sp-dev-docs/issues/7826) - [SPFx 1.15.0-beta.1] package-solution fails when elements.xml file is referenced from external folder and sharepoint/assets doesn't exist
100
-
-[#6477](https://github.com/SharePoint/sp-dev-docs/issues/6477) - Subscribe to list notifications with transport error
101
-
-[#7845](https://github.com/SharePoint/sp-dev-docs/issues/7845) - `command.disabled` not always respected
102
-
-[#6807](https://github.com/SharePoint/sp-dev-docs/issues/6807) - SharePoint spfx webparts seem to be taking up all sessionStorage in the browser
103
-
-[#7684](https://github.com/SharePoint/sp-dev-docs/issues/7684) - SPFx app inside Microsoft Teams authentication error (sso-getAdalSsoToken-receive)
104
-
-[#7739](https://github.com/SharePoint/sp-dev-docs/issues/7739) - CommandSet Extensions don't work in Document Library when navigating from LHN link on site home page
105
-
-[#7794](https://github.com/SharePoint/sp-dev-docs/issues/7794) - `listViewStateChangedEvent` does not trigger for grouped list views
106
-
-[#7805](https://github.com/SharePoint/sp-dev-docs/issues/7805) - SPFx is loading library component old version for some users
-[#7680](https://github.com/SharePoint/sp-dev-docs/issues/7680) - Theme colors do not load (immediately) on SP listpage or site contents page
109
98
-[#6403](https://github.com/SharePoint/sp-dev-docs/issues/6403) - DynamicData.tryGetValue() should not fail if disposed
110
99
-[#5979](https://github.com/SharePoint/sp-dev-docs/issues/5979) - Problem popup when remove SPFx Teams Tab
111
100
-[#7679](https://github.com/SharePoint/sp-dev-docs/issues/7679) - Field customizer doesn't load consistently when searching
112
101
-[#7689](https://github.com/SharePoint/sp-dev-docs/issues/7689) - [SPFx-Heft-Plugins][SPFx 1.13.1] elementManifests path resolving differently on Windows and Linux when referencing external file path
113
102
-[#7771](https://github.com/SharePoint/sp-dev-docs/issues/7771) - SPFx v1.14.0: Image Helper API, exception in btoa, string contains characters outside of the Latin1 range
103
+
-[#7684](https://github.com/SharePoint/sp-dev-docs/issues/7684) - SPFx app inside Microsoft Teams authentication error (sso-getAdalSsoToken-receive)
104
+
-[#7739](https://github.com/SharePoint/sp-dev-docs/issues/7739) - CommandSet Extensions don't work in Document Library when navigating from LHN link on site home page
105
+
-[#7794](https://github.com/SharePoint/sp-dev-docs/issues/7794) - `listViewStateChangedEvent` does not trigger for grouped list views
106
+
-[#7805](https://github.com/SharePoint/sp-dev-docs/issues/7805) - SPFx is loading library component old version for some users
-[#7827](https://github.com/SharePoint/sp-dev-docs/issues/7827) - `deploy-azure-storage` command always creates container with Pubic Access Level of 'Private' instead of Blob
109
+
-[#7826](https://github.com/SharePoint/sp-dev-docs/issues/7826) - [SPFx 1.15.0-beta.1] package-solution fails when elements.xml file is referenced from external folder and sharepoint/assets doesn't exist
110
+
-[#6477](https://github.com/SharePoint/sp-dev-docs/issues/6477) - Subscribe to list notifications with transport error
111
+
-[#7845](https://github.com/SharePoint/sp-dev-docs/issues/7845) - `command.disabled` not always respected
112
+
-[#6807](https://github.com/SharePoint/sp-dev-docs/issues/6807) - SharePoint spfx webparts seem to be taking up all sessionStorage in the browser
113
+
-[#7950](https://github.com/SharePoint/sp-dev-docs/issues/7950) - `globalDependecies` in `config.json` don't work
114
+
-[#7949](https://github.com/SharePoint/sp-dev-docs/issues/7949) - `command.disabled` still not working
115
+
-[#7974](https://github.com/SharePoint/sp-dev-docs/issues/7974) - Property `folderInfo` is undefined if folder is loaded directly
0 commit comments