Share via

PowerShell script Error for sharepointsite development -- Add-SPOSiteScript : Action 2 (createSPList) is invalid. List subaction 2 (addSPField) is invalid. Parameter fieldType has an invalid value.

Anonymous
2024-11-22T23:10:01+00:00

I am getting following Error for the PowerShell script I have developed which trying to create a organization site template

-- Add-SPOSiteScript : Action 2 (createSPList) is invalid. List subaction 2 (addSPField) is invalid. Parameter fieldType has an invalid value.

I am using valid data types however I am still getting error

fieldType Values:

  • For "Event Date": fieldType is "DateTime".
  • For "Location": fieldType is "Text".
  • For "News Link": fieldType is "URL".

JSON Script ---

# Set Parameters

$AdminCenterURL = "xxx.sharepoint.com"  # Admin Center URL

$SiteURL = "https://xxx.sharepoint.com/sites/CommunicationSite"  # Site URL

# Connect to SharePoint Online Admin Center

Connect-SPOService -Url $AdminCenterURL

# Define the Site Script

$siteScript = @"

{

  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",

  "actions": [

    {

      "verb": "createSPList",

      "listName": "Events",

      "templateType": 106,

      "subactions": [

        {

          "verb": "setTitle",

          "title": "Upcoming Events"

        },

        {

          "verb": "addSPField",

          "fieldType": "DateTime",

          "displayName": "Event Date",

          "internalName": "EventDate",

          "isRequired": false

        },

        {

          "verb": "addSPField",

          "fieldType": "Text",

          "displayName": "Location",

          "internalName": "Location",

          "isRequired": false

        }

      ]

    },

    {

      "verb": "createSPList",

      "listName": "News Links",

      "templateType": 103,

      "subactions": [

        {

          "verb": "setTitle",

          "title": "Company News"

        },

        {

          "verb": "addSPField",

          "fieldType": "URL",

          "displayName": "News Link",

          "internalName": "NewsLink",

          "attributes": {

            "Format": "Hyperlink"

          },

          "isRequired": false

        }

      ]

    }

  ],

  "version": 1

}

"@

Write-Output $siteScript

# Create the Site Script

$siteScriptId = Add-SPOSiteScript -Title "xxx  Portal v5" -Content $siteScript

# Create the Site Design

Add-SPOSiteDesign -Title "xxx  Communication Site V5" -WebTemplate "68" -SiteScripts $siteScriptId -Description "Organization communication site template for xxx"

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-11-23T02:22:01+00:00

    Hi Vijay Pimple,

    As per the shared information, it sounds like you're encountering error in the PowerShell script on creating a organization site template. In this situation, as community moderators here mainly focus on OFB features in SharePoint Online, to make sure you can get the professional and appropriate support from escalated SharePoint engineers, please post in Microsoft Q&A Community, which is the specific channel to handle such developed customization. You may use SharePoint Development tag when" Ask a question".

    Image

    Meanwhile, I will keep your thread open here and welcome other community members or MVPs may share their suggestions and experience for you.

    Please correct me if I made any misunderstanding or if there have anything else I can do for you.

    Your patience is highly appreciated. Hope you a nice day and stay safe!

    Best Regards,

    Mia

    Was this answer helpful?

    0 comments No comments