Skip to content

Error when using SharePoint Site Script to create a list with subaction "setTitle" #10483

@michaelmaillot

Description

@michaelmaillot

Target SharePoint environment

SharePoint Online

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

SharePoint REST API

Developer environment

None

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

No response

Describe the bug / error

Hello,

In our site templates, we use site scripts and we met an issue with a specific action.

We wanted to use the "createSPList" action to create a list (template type 100) and rename it in order to distinct explicit title from technical one (URL).

Below the JSON content of the site script:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
  "actions": [
    {
      "verb": "createSPList",
      "listName": "testlist",
      "templateType": 100,
      "subactions": [
        {
          "verb": "setTitle",
          "title": "Feedback"
        }
      ]
    }
  ]
}

When I want to apply it to a site, I run the following POST query:

https://[TENANT_URL].sharepoint.com/sites/[SITE_URL]/_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ExecuteTemplateScript()

However, here's the returned error I have:

{
    "odata.metadata": "https://[TENANT_URL].sharepoint.com/sites/[SITE_URL]/_api/$metadata#Collection(Microsoft.SharePoint.Utilities.WebTemplateExtensions.SiteScriptActionResult)",
    "value": [
        {
            "ErrorCode": -2147467259,
            "Outcome": "1",
            "OutcomeText": null,
            "Target": null,
            "TargetId": null,
            "Title": "Créer ou mettre à jour la liste « testlist »",
            "Verb": "createSPList"
        }
    ]
}

But if I try to run the same query when creating a library instead of a list (template type 101), here's the returned content:

{
    "odata.metadata": "https://[TENANT_URL].sharepoint.com/sites/[SITE_URL]/_api/$metadata#Collection(Microsoft.SharePoint.Utilities.WebTemplateExtensions.SiteScriptActionResult)",
    "value": [
        {
            "ErrorCode": 0,
            "Outcome": "0",
            "OutcomeText": null,
            "Target": "https://[TENANT_URL].sharepoint.com/sites/[SITE_URL]/testlist",
            "TargetId": "5b093d3b-1365-459f-82c2-741482e97f01",
            "Title": "Créer ou mettre à jour la bibliothèque « testlist »",
            "Verb": "createSPList"
        },
        {
            "ErrorCode": 0,
            "Outcome": "0",
            "OutcomeText": null,
            "Target": null,
            "TargetId": null,
            "Title": "Définir le titre de la liste sur « Feedback»",
            "Verb": "createSPList.setTitle"
        }
    ]
}

I didn't find anything in the documentation about limitations of the subaction "setTitle", and the returned error is not explicit.

Steps to reproduce

  1. Open a console or an app with which you can perform HTTP POST calls
  2. Type the URL https://[TENANT_URL].sharepoint.com/sites/[SITE_URL]/_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ExecuteTemplateScript() and replace [TENANT_URL] & [SITE_URL] with real values
  3. Setup header parameters (bearer token or cookie value) and add in the body the "createSPList" action with "setTitle" subaction

Expected behavior

As there's nothing declared in the documentation regarding limitation in "setTitle" subaction between Generic List (template type 100) & Document Library template type 101), I expect this to work. And if there's a specific error, I expect a clear outcome message.

Metadata

Metadata

Assignees

Labels

area:site-designCategory: Site Designs/Site Scriptssharepoint-developer-supportsharepoint-developer-supporttype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions