I work with SP2013 on-premises publishing site. There is a standard Content Type named 'Article Page', it includes field PublishingPageContent, which type is HTML.

When I create a page inside Page library and insert iframe code inside PublishingPageContent field, iframe code shows video from the same SP server's assets library, all displayed well.

For some purpose I added custom HTML field to the content type. But the problem is when I add the same iframe code to this custom field it got deleted on page save. So what is so special about PublishingPageContent field?

I tried to analyze differences between PublishingPageContent and custom HTML field using PowerShell. Maybe the only difference worth to be mentioned is RichTextMode property: in case of PublishingPageContent it is "FullHtml", in case of custom HTML it is "ThemeHtml". I tried to set RichTextMode to "FullHtml" for custom HTML field but had no luck.

Can somebody help me to understand is there is a way to make custom HTML field to behave the same way as PublishingPageContent? Or at least make it not delete iframe script? =)

Thank you!

Update: PowerShell script to update site's column

$sourceWeb = Get-SPWeb "https://shp-dev"
$listPages = $sourceWeb.Lists["Pages"] # Use list's display name
$customFieldName = "CustomHTML"; # your custom field inner name
$listField = $listPages.Fields | Where { $_.StaticName -eq $customFieldName }
write-host $listField[0].RichTextMode;

# uncomment next two lines to update field
# $listField[0].RichTextMode = "FullHtml";
# $listField[0].Update();


You may want to retest with the RichTextMode set to FullHtml. Indeed, here's what we can see in the code of RichHtmlField.Validate (as seen after reflecting with ILSpy):

bool allowIframes = htmlField.RichText && htmlField.RichTextMode == SPRichTextMode.FullHtml;
  • So I was right about .RichTextMode. Thank you, @Evariste. Unfortunatelly it is standard functionality of SharePoint, not my server code. Do you know is it possible to change this property using PowerShell? I was trying to set it straight, but calling .Update() throws an error, something like "field type cannot be updated" (I have this message in Ukrainian, so I'm not sure how it sounds in English) – Roman_K Jun 7 '18 at 7:26
  • I wanted to add that I was able to change site column, but wasn't able to update list column which is derived from site column. – Roman_K Jun 7 '18 at 7:44
  • Something fun happening inside SP. I deleted all pages created with my content type, which holds custom HTML column, and added it again, now list field .RichTextMode = "FullHtml" and it doesn't remove iframe in new pages. I wonder now, how to change my custom column in working list full of documents which I cannot remove! =) – Roman_K Jun 7 '18 at 8:15
  • I'm not completely surprised you cannot update a field attached to a list via a content type (at least for some attributes of the field). The standard approach would be to update the site column, and calling Update(true) so that the change propagates down to the list level. – Evariste Jun 7 '18 at 10:16
  • I did exactly what you said, actually (maybe I explained not well) =) And also tried calling Update(true). Site column updated successfully, but list field didn't. It seems that list field cannot be updated while there are items in the list. – Roman_K Jun 7 '18 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.