Showing posts with label 'HyperLink or Picture Type' SPFieldValidationException.. Show all posts
Showing posts with label 'HyperLink or Picture Type' SPFieldValidationException.. Show all posts

Monday, February 1, 2016

Programatically assign value to a 'Hyperlink or Picture Type' column in a SharePoint 2016 List

Recently I had a requirement to collect publishing pages URLs in a SharePoint 2016 List. Adding an item in a list is straight forward and that's probably the first development task every SharePoint developer does.

But I was not able to find enough resources on adding a 'HyperLink or Picture Type' column in an SPList.

Below is the code snippet to assign value to a hyper link column.

Hyper link column expects value in <ABSOLUTE URL>, <TITLE> format.

Important thing to note here is that hyperlink should always start with 'http://'. If you try to assign a relative URL or a URL which starts with 'www', you will always get SPFieldValidationException.

Hope it will help.