Forum Discussion

Gary_Stewart's avatar
Gary_Stewart
Copper Contributor
May 07, 2019

Site Scripts and Hyperlink/Picture Site Columns

I am developing a site script to create some site columns and content types.  Mostly it is working OK, but I'm having trouble figuring out how to use the createSiteColumnXml verb to create a hyperlink/picture field.  First I tried this:

"schemaXml": "<Field Type=\"Url\" DisplayName=\"MsgImage\" Required=\"FALSE\" Format=\"Image\" StaticName=\"MsgImage\" Name=\"MsgImage\" Group=\"_ActsCustom\"></Field>"
 

That didn't work.  After some additional research I thought maybe I needed to include a value for ID, so I generated a GUID and changed it to:

 

"schemaXml": "<Field Type=\"Url\" DisplayName=\"MsgImage\" Required=\"FALSE\" Format=\"Image\" StaticName=\"MsgImage\" Name=\"MsgImage\" Group=\"_ActsCustom\" ID=\"{23ed08db-f248-42ef-9ea7-d615fdeca8c2}\"></Field>"
 
That fails as well.  Any ideas how I should modify this to make it work?

4 Replies

  • 0verLogging's avatar
    0verLogging
    Copper Contributor

    Gary_Stewart I got this working for URL fields:

     

    {
    "verb": "addSPFieldXml",
    "schemaXml":"<Field Type=\"URL\" DisplayName=\"Website\" Required=\"FALSE\" Format=\"Hyperlink\" StaticName=\"Website\" Name=\"Website\"></Field>",
    "addToDefaultView": true
    },

      • Beau Cameron's avatar
        Beau Cameron
        MVP

        Gary_Stewart I would suggest creating the the picture field on a list and using PowerShell command "Get-SPOSiteScriptFromList" to extract out the values you need. 

        "schemaXml": "<Field DisplayName=\"TestPicture\" Format=\"Image\" Name=\"TestPicture\
        " Title=\"TestPicture\" Type=\"URL\" ID=\"{6f2db82c-f1a6-415d-9678-324b1d809f17}\" StaticName=\
        "TestPicture\" />"

Resources