none
Create Content Type and add to SharePoint list with Powershell RRS feed

  • Question

  • Hi,

    I created PowerShell Script, that install custom content type and create custom Lists in SharePoint Online site.

    The content type contains calculated column and If I want to add the content type to the Generic List I get error: 

    Microsoft.SharePoint.Client.ServerException: The formula contains a syntax error or is not supported by the system.

    $context.Load($list.ContentTypes)
    $context.ExecuteQuery()
    $list.ContentTypesEnabled = $True
    $list.Update()
    $context.ExecuteQuery()
    $newListCT = $list.ContentTypes.AddExistingContentType($newContentType)
    $context.Load($ikCT)
    $context.ExecuteQuery()

    If I add the content type in the browser to the list, then it works fine.

    My SharePoint tenant language is Hungarian, maybe there is a problem?

    Please help!

    Thanks,

    Mykie

    Thursday, October 31, 2019 10:30 AM

All replies

  • Hi Mykie,

    Did you add the formula in the calculated column?

    If so, you could check if the formula is correct in the calculated column.

    And you also create a new calculated column in one list and add the same formula into the new calculated column to check if it can work.

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, November 1, 2019 6:28 AM
    Moderator
  • Hi,

    sorry the column type is text and I set the default value with calculated value:

    <DefaultFormula>=TEXT(Today;"yyyy")&amp;"/"&amp;TEXT(Today;"mm")</DefaultFormula>

    BR,

    Mykie

    Monday, November 4, 2019 9:47 AM