CHunky Universe of Vigourous Astonishing SHarepoint :)

JSOM: Alter a column’s ShowInDisplayForm property

When you create a content type, you can define if your fields will be shown in DisplayForm, EditForm, NewForm. You can hide or show them, just as Yaroslav Pentsarsky says. If your list is already provisioned, you can change them with Server Object Model, why not in PowerShell: Technet: Setting ShowInDisplayForm, ShowInEditForm, ShowInNewForm properties with powershell.

If you don’t have access to the server, then the same can be done with JSOM. Here is the code:

var ctx = SP.ClientContext.get_current(),              //SP.ClientContext
    field = ctx.get_web()                              //SP.Web
               .get_lists()                            //SP.ListCollection
               .getByTitle('MyList')                   //SP.List
	       .get_fields()                           //SP.FieldCollection
	       .getByInternalNameOrTitle("Site");      //SP.Field
ctx.load(field, "SchemaXml");                          //load only SchemaXml
ctx.executeQueryAsync(function() {
	var s = field.get_schemaXml(),
	    s1 = s.replace('ShowInDisplayForm="FALSE"', 

Next: JSOM: Alter a column’s DisplayName.

8 responses to “JSOM: Alter a column’s ShowInDisplayForm property

  1. Naveen 2013-05-28 at 09:55

    Please find the below code
    var ctx = SP.ClientContext.get_current(),
    field = ctx.get_site()
    .getByInternalNameOrTitle(“Product Type”);
    ctx.load(field, “SchemaXml”);
    ctx.executeQueryAsync(function () {
    var s = field.get_schemaXml();

    $(‘#resultpanel’).append(‘****************************** original: ‘ + s);

    s1 = s.replace(‘00000000-0000-0000-0000-000000000000’,

    s2 = s1.replace(‘00000000-0000-0000-0000-000000000000’,

    $(‘#resultpanel’).append(‘****************************** updating with: ‘ + s2);

    ctx.executeQueryAsync(Function.createDelegate(this, function () {
    $(‘#resultpanel’).append(‘****************************** after Update from get_schemaXml: ‘ + field.get_schemaXml());
    Function.createDelegate(this, function (sender, args) {

    $(‘#resultpanel’).append(‘ Error – from OnLoadSuccess: ‘ + args.get_message());


    I am not finding any change in the field after i run this code. You see any mistake in my code.

    In the success delegate, from field.get_schemaXml() i can see the updated schema. But still its not getting reflected on the field.

    Any help is appreciated…

    • Anatoly Mironov 2013-05-28 at 10:14

      What do you try to do? Why is the guid empty first? Have you tried some other change, like ShowInDisplayForm (from my example)? Just to verify that everything else works.

      • Naveen 2013-05-28 at 14:00


        Thanks for quick reply. When I pasted my code here this editor is actually hiding some xml markup. Anyhow I am trying to update the SspId, TermSetId property values for the field. I was able to change all the attribute values of the SP.field that is anything from below

        but could not change anything inside

        I am trying to use set_schemaXml method

      • Anatoly Mironov 2013-05-31 at 09:27

        Allright, if you can update all other properties, but not SspId, TermSetId, then it is something else that prevent updating it. I have not tried to update those properties with set_schemaXml. Maybe in the future, I’ll find time to investigate why it is so. If you find something, please leave a comment here.

  2. StackAndChill 2013-08-14 at 22:22

    I can’t get this working in my Office365 dev environment. Is it possible to set the XML schema in office 365?

    • Anatoly Mironov 2013-08-15 at 09:35

      Hi, it should work in Office 365, too. I haven’t tried it out, though. When you try to do in, check the response you get from the ajax call. You can see it in the Developer tools of your browser. Often you’ll get a good error message there.

  3. Egidio Caleiro Santoro 2016-04-01 at 02:15

    I’ve made a mistake in my provisiong scripts and all of my custom get_web().get_fields() are with incorrect WebId values, so are all of my custom content types that contain them. I’ve already updated the Fields in my web FieldCollection, but my ContentTypes remains incorrect. Problem is that get_web().get_contentTypes() just exposes a setter for schemaXmlWithResourceTokens method. Any idea on how can replace Contettype SchemaXml? Thank u in advance!

  4. Nadeem Yousuf 2018-04-18 at 07:01

    Thanks for sharing. Good post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...

%d bloggers like this: