CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: SPField

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.


AfterProperties kräver InternalName

AfterProperties kommer inte leda till Exception, men de kommer returnera bara null, om du använder DisplayName. Man måste ha InternalName. Här är ett litet exempel på hur man kan få ut värden före och efter uppdateringen. Exemplet har testats i ItemUpdated-eventreceiver.

var before = properties.BeforeProperties;
var after = properties.AfterProperties;
var contentDisplayName = "News Content";
var list = properties.List;
var contentInternalName = list.Fields[contentDisplayName].InternalName;
var contentBefore = before[contentInternalName];
var contentAfter = after[contentInternalName];

field type

Här är en hel lista över olika typer som Field kan få i Content Type. Type=”File” motsvarar SPFieldFile

ID på befintliga kolumner

Det finns en fin lista över id på kolumner som man kan lägga till. Här är ett exempel hur man kan använda det.

Här är ett exempel på två extra kolumner i contenttype:

      <FieldRef ID="{23f27201-bee3-471e-b2e7-b64fd8b7ca38}"/>
      <!-- Enterprise Keywords-->
      <FieldRef ID="{3de94b06-4120-41a5-b907-88773e493458}"/>
      <!-- PublishingImage-->

Komma åt Title-kolumnen i SPList

Vad gör man om man vill lägga till Title-kolumnen till en ny vy?

SPField fieldTitle = scheduleList.Fields["Title"];

Det kommer funka, men Title kommer vara bara text, utan en länk till SPListItem.

Kolla på den koden:

SPField fieldTitle = scheduleList.Fields[SPBuiltInFieldId.LinkTitle];

Här hämtar vi kolumnen som heter i Sharepoint “Title linked with item menu”. Det finns fler sådana “inbygda” kolumner.

Вула Чăвашла

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

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, 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

Toronto Blockchain Consulting and Smart Contract Development


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