CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

JSOM: Alter a column’s DisplayName

Here is another article in my JSOM series. For one month ago I showed how to alter a column’s ShowInDisplayForm property with JSOM. This time I’ll show a code sample for changing a column’s (field’s) display name. If you want to alter the displayname with Server Object Model, grab the code in the sharepoint.stackexchange.com: Change Field’s DisplayName in a List.

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("Body");      //SP.Field
ctx.load(field, "Title");                              //load only Title
ctx.executeQueryAsync(function() {
	field.set_title("Beskrivning");
	field.update();
	ctx.executeQueryAsync();
});
Advertisements

4 responses to “JSOM: Alter a column’s DisplayName

  1. Bill 2016-03-04 at 15:16

    This will change the field’s Internal Name. I just want to change the field’s Display Name and keep the original Internal Name.

  2. Bill 2016-03-06 at 20:40

    Thanks for helping.
    We are using CSOM – Javascript – SharePoint 2013
    We need to first create the field with a field name like xxxFieldName with no spaces. This will be our internal name. Now, we need to change the display name from xxxFieldName to ‘The Field Name’ without changing the internal name. Unfortunately, the internal name gets gets changed to ‘The Field Name’.
    &Field=The%5Fx0020%5FField%5Fx0020%5FName
    we need
    &Field=xxxTheFieldName

    We used PowerShell scripts before. It works fine. The field Internal names stay as they were when first created and only the display name changes.

    There are some significant bugs in CSOM Javascript.

    • Bill 2016-03-08 at 16:10

      Here is the answer to my question.
      When first creating the field using JSOM, I am using oFields.addFieldAsXml.
      The xml field node string MUST have the DisplayName attribute value set to the Internal Name before calling addFieldAsXml.
      Once the field is created, using set_title will not change the field’s Internal Name.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

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

RealActivity - Real-time and trustworthy

Blog site of founder, RealActivty - Paul J. Swider

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

paul.tavares

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

SPJoel

SharePoint for everyone

SharePointRyan

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, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis

%d bloggers like this: