Site Scripts and Hyperlink/Picture Site Columns

%3CLINGO-SUB%20id%3D%22lingo-sub-543309%22%20slang%3D%22en-US%22%3ESite%20Scripts%20and%20Hyperlink%2FPicture%20Site%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-543309%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20developing%20a%20site%20script%20to%20create%20some%20site%20columns%20and%20content%20types.%26nbsp%3B%20Mostly%20it%20is%20working%20OK%2C%20but%20I'm%20having%20trouble%20figuring%20out%20how%20to%20use%20the%20createSiteColumnXml%20verb%20to%20create%20a%20hyperlink%2Fpicture%20field.%26nbsp%3B%20First%20I%20tried%20this%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%22schemaXml%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22%3CFIELD%20type%3D%22%5C%26quot%3BUrl%5C%26quot%3B%22%20displayname%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20required%3D%22%5C%26quot%3BFALSE%5C%26quot%3B%22%20format%3D%22%5C%26quot%3BImage%5C%26quot%3B%22%20staticname%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20name%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20group%3D%22%5C%26quot%3B_ActsCustom%5C%26quot%3B%22%3E%3C%2FFIELD%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EThat%20didn't%20work.%26nbsp%3B%20After%20some%20additional%20research%20I%20thought%20maybe%20I%20needed%20to%20include%20a%20value%20for%20ID%2C%20so%20I%20generated%20a%20GUID%20and%20changed%20it%20to%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%22schemaXml%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22%3CFIELD%20type%3D%22%5C%26quot%3BUrl%5C%26quot%3B%22%20displayname%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20required%3D%22%5C%26quot%3BFALSE%5C%26quot%3B%22%20format%3D%22%5C%26quot%3BImage%5C%26quot%3B%22%20staticname%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20name%3D%22%5C%26quot%3BMsgImage%5C%26quot%3B%22%20group%3D%22%5C%26quot%3B_ActsCustom%5C%26quot%3B%22%20id%3D%22%5C%26quot%3B%7B23ed08db-f248-42ef-9ea7-d615fdeca8c2%7D%5C%26quot%3B%22%3E%3C%2FFIELD%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThat%20fails%20as%20well.%26nbsp%3B%20Any%20ideas%20how%20I%20should%20modify%20this%20to%20make%20it%20work%3F%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-543309%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-544133%22%20slang%3D%22en-US%22%3ERe%3A%20Site%20Scripts%20and%20Hyperlink%2FPicture%20Site%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-544133%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330577%22%20target%3D%22_blank%22%3E%40Gary_Stewart%3C%2FA%3E%26nbsp%3B%20I%20don't%20believe%20you%20can%20create%20that%20type%20of%20column%20in%20site%20scripts%20at%20the%20moment.%26nbsp%3B%20This%20is%20a%20good%20tool%20to%20see%20what%20is%20available%20at%20the%20moment%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.sitedesigner.io%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.sitedesigner.io%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-548014%22%20slang%3D%22en-US%22%3ERe%3A%20Site%20Scripts%20and%20Hyperlink%2FPicture%20Site%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-548014%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2552%22%20target%3D%22_blank%22%3E%40Tanya%20Denton%3C%2FA%3E%26nbsp%3Bthanks.%26nbsp%3B%20That%20is%20a%20pretty%20handy%20tool.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-548255%22%20slang%3D%22en-US%22%3ERe%3A%20Site%20Scripts%20and%20Hyperlink%2FPicture%20Site%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-548255%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330577%22%20target%3D%22_blank%22%3E%40Gary_Stewart%3C%2FA%3E%26nbsp%3BI%20would%20suggest%20creating%20the%20the%20picture%20field%20on%20a%20list%20and%20using%20PowerShell%20command%20%22Get-SPOSiteScriptFromList%22%20to%20extract%20out%20the%20values%20you%20need.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CPRE%3E%22schemaXml%22%3A%20%22%26lt%3BField%20DisplayName%3D%5C%22TestPicture%5C%22%20Format%3D%5C%22Image%5C%22%20Name%3D%5C%22TestPicture%5C%0A%22%20Title%3D%5C%22TestPicture%5C%22%20Type%3D%5C%22URL%5C%22%20ID%3D%5C%22%7B6f2db82c-f1a6-415d-9678-324b1d809f17%7D%5C%22%20StaticName%3D%5C%0A%22TestPicture%5C%22%20%2F%26gt%3B%22%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-744362%22%20slang%3D%22en-US%22%3ERe%3A%20Site%20Scripts%20and%20Hyperlink%2FPicture%20Site%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-744362%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330577%22%20target%3D%22_blank%22%3E%40Gary_Stewart%3C%2FA%3E%26nbsp%3BI%20got%20this%20working%20for%20URL%20fields%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7B%3CBR%20%2F%3E%22verb%22%3A%20%22addSPFieldXml%22%2C%3CBR%20%2F%3E%22schemaXml%22%3A%22%3CFIELD%20type%3D%22%5C%26quot%3BURL%5C%26quot%3B%22%20displayname%3D%22%5C%26quot%3BWebsite%5C%26quot%3B%22%20required%3D%22%5C%26quot%3BFALSE%5C%26quot%3B%22%20format%3D%22%5C%26quot%3BHyperlink%5C%26quot%3B%22%20staticname%3D%22%5C%26quot%3BWebsite%5C%26quot%3B%22%20name%3D%22%5C%26quot%3BWebsite%5C%26quot%3B%22%3E%3C%2FFIELD%3E%22%2C%3CBR%20%2F%3E%22addToDefaultView%22%3A%20true%3CBR%20%2F%3E%7D%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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

@Gary_Stewart  I don't believe you can create that type of column in site scripts at the moment.  This is a good tool to see what is available at the moment https://www.sitedesigner.io

@Tanya Denton thanks.  That is a pretty handy tool.

@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\" />"

@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
},