Expand Minimize

SPF019913: Ensure that Web Part properties used in code are defined in the Web Part manifest

All Web Part properties used in code must be defined in the Web Part manifest

CheckId SPF019913
TypeName DefineWebPartPropertiesSpecifiedInCodeInTheManifest
Severity CriticalError
Type JavaScriptFile

Whenever defining a Web Part property in the Web Part manifest the same property should be defined in Web Part's code so that it's configurable through the property pane.

WeatherWebPart.manifest.json

{
  "$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",

  "id": "8908df13-a965-4445-9c48-ecec77c44be4",
  "alias": "WeatherWebPart",
  "componentType": "WebPart",
  "version": "0.0.1",
  "manifestVersion": 2,

  "preconfiguredEntries": [{
    "groupId": "8908df13-a965-4445-9c48-ecec77c44be4",
    "group": { "default": "Default" },
    "title": { "default": "Weather" },
    "description": { "default": "Shows weather for the given place" },
    "officeFabricIconFontName": "Sunny",
    "properties": {
      "location": ""
    }
  }]
}


WeatherWebPart.ts
import { Version } from '@microsoft/sp-core-library';
import {
  BaseClientSideWebPart,
  IPropertyPaneConfiguration,
  PropertyPaneTextField
} from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';

import styles from './Weather.module.scss';
import * as strings from 'weatherStrings';
import { IWeatherWebPartProps } from './IWeatherWebPartProps';

export default class WeatherWebPart extends BaseClientSideWebPart<IWeatherWebPartProps> {
  public render(): void {
    // omitted for brevity
  }

  protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
    return {
      pages: [
        {
          header: {
            description: strings.PropertyPaneDescription
          },
          groups: [
            {
              groupName: strings.DataGroupName,
              groupFields: [
                PropertyPaneTextField('location', {
                  label: strings.LocationFieldName
                })

              ]
            }
          ]
        }
      ]
    };
  }
}

Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.