2

I am trying to create Enhanced Rich Text field on SharePoint Online list using SPFx. Tried below code. Its creating just Multiline field with restricted rich text, not the Enhanced Rich Text field. I tried adding this "RichTextMode": "FullHtml", and its throwing error 400 not allowing to create field. Please highlight if am missing/correct anything. Thanks in advance.

  const fieldsClientOptions: ISPHttpClientOptions = {
  body: JSON.stringify({
    "@odata.type": "#SP.FieldMultiLineText",
    "FieldTypeKind": 3,
    "Title": "Value",
    "StaticName": "Value",
    "NumberOfLines": 6,
    "RichText": true,
    "EnforceUniqueValues": false
  })
};

const fieldQry: string = this.context.pageContext.web.absoluteUrl + "/_api/web/lists/getByTitle('customlist')/fields";
this.context.spHttpClient.post(fieldQry, SPHttpClient.configurations.v1, fieldsClientOptions).then(
  (responseColumn: SPHttpClientResponse) => {
    console.log("Column creation status.."+responseColumn.status);
    if (responseColumn.status == 201) {
      console.log("column created successfully");
    }
  }).catch((error: any) => {
    console.log("Error creating column: " + error);
});

1 Answer 1

1

You can refer to the following article to create Enhanced Rich Text field using SPFx https://nanddeepnachanblogs.com/posts/2020-03-19-rich-text-control-in-spfx/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.