Various ECMA List field operations in SharePoint 2013/2016

jsom sharepoint
SharePoint deveopment training course

In the SharePoint client object model, ECMA plays key role. I would like to walk you through various methods to access list fields or columns using ECMA scripting.

ECMA script client object model is nothing but same as the JavaScript client object model also known as JSOM in SharePoint.

Note: Like as in the C# object model, in ECMA also we need to use the SharePoint list field internal name.

ECMA List field operations in SharePoint 2013/2016

Title:
This is the default filed will get created as soon as we create a SharePoint list with Item content type. To read Title field

Syn:
To read value: ObjListItem.get_item(‘Title’)
To set value: ObjListItem.set_item(‘Title’, “Title Value”);

ID:
The default column get creates with the list and it is an auto incremental field.

Syn:
To get ID: ObjListItem.get_id()

URL/Hyperlink Field: In SharePoint URL field will have to set 2 values 1 is URL and the other one is description.

Syn:
To get URL value – ObjListItem.get_item(‘urlfieldname’).get_url()
To set URL value – ObjListItem.set_item(‘urlfieldname’,”URL field Value”)
To get description value – ObjListItem.get_item(‘descriptionfieldname’).get_description();
To set description value – ObjListItem.set_item(“descriptionfieldname”,”description Value”);

Setting Hyperlink Field from UI:
Below is the way you can set hyperlink field through UI in SharePoint 2013.

sharepoint ecmascript

Hyperlink list field:

ecmascript sharepoint

Version Details:
To get the version details of a SharePoint list item.

Syn:
To read the version details: ObjListItem.get_item(“_UIVersionString”)

Choice field:
In SharePoint, we have a field to facilitate selecting a single value from a list of values.

Syn:
To get the value: ObjListItem.get_item(‘ChoiceFieldName’)
To set the value: ObjListItem.set_item(‘ChoiceFieldName’,’Choice Value’)

ecmascript sharepoint 2013 examples

Created Date:
SharePoint creates the default time stamp as soon as list item get created.

Syn:
To get the time stamp: objListItem.get_item(“Created”)

Modified Date:
SharePoint also tracks updated date time.

Syn:
To get the updated timestamp: objListItem. get_item(“Modified”)

Created User Name:
As we learned just before SharePoint keep track of all the operations and user accounts operated with. This will get the Created User Name.

Syn:
To get the created User Name: objListItem.get_item(“Author”).get_lookupValue()

Modified User Name:
Now that we learned to get the created user, the below will get the modified user name.

Syn:
Modified User Name: objListItem.get_item(“Editor”).get_lookupValue()

List Item Content Type:
As we learned at the beginning of the article list will get associate with one content type. If we need to know the content type associated with the list item.

Syn:
To know the Content Type: objListItem.get_contentType()

You may like following SharePoint client object model tutorials:

Hope this helps, happy development in the SharePoint Object model.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Krishna Vandanapu

I am Krishna.Vandanapu a SharePoint architect working in IT from last 13+ years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019

View all posts by Krishna Vandanapu →