9 minute read
SharePoint Custom Development

Developing custom SharePoint functionalities using JavaScript Client Object Model without on-premises App Infrastructure setup

We know to provide infrastructure support for SharePoint Apps we have to do a number of configuration steps. I have worked for a number of business where the App infrastructure for their on-premises SharePoint farm has not been set up but there are some important business requirement to be implemented without trusted solution and managed code as a practice. In this article I will show you a structured way of developing custom SharePoint functionalities using JavaScript CSOM and jQuery which is very compatible with SharePoint hosted Apps.


The main components that are required to develop client side functionality are HTML, CSS, and JavaScript along with SharePoint list/libraries which holds related data. You can just use SharePoint designer as the only tool to develop these components or any of your favorite editor is good. I will demonstrate the structure and separation of code using SharePoint designer:

1. Open you site using SharePoint Designer and on the navigation click on “Site Assets”.

2. Now because you can have multiple custom functionalities, for a good structure and code management you can create following folder structure:


Each separate functionalities could be a subfolder under “Utilities folder.

3. Say you are developing a functionality for showing announcements, so you can create following three files under “AnnouncementTicker” folder:


Do your required coding for the components. Refer to the “.css” and “.js” files from the .”html” files.

4. Now as your custom coded components are ready, open the page in browser where you need to add the functionality. Edit the page and add a Content Editor Web Part in the required zone and link the “.html” file. In the Content Editor Tool Pane, under Content Link, type the link of the “.html” file, for example “SiteAssets/Resources/Utilities/AnnouncementTicker/AnnouncementTicker.html”.

5. Save the page and you can see the results. For updating the functionality you do not need any deployment. Just edit the code from the corresponding files using SharePoint Designer and save to see the update in browser.

Pretty fast and efficient development process compared to SharePoint Hosted App Development!

A real life example will be good and for this I am demonstrating the “Announcement Ticker” functionality to be added on a say dashboard page:

1. Create a SharePoint List “Announcements” which will host all announcement/notification/news details.


2. Only the active announcements (current date within publishing start and end date time) will display on dashboard page. This way you can set up future announcements and will automatically display on dashboard when start date time appears and will expire from dashboard after the specified publishing end date time.

If an announcement contains an external link, clicking on “More” button will open the link in a new window else the announcement details will appear in a modal window.

3. You can configure multiple active announcements and those active announcements will scroll one by one on dashboard page.

I have used JQuery, Bootstrap and SharePoint JavaScript Client Object Model as the main technologies for the solution. Use SharePoint designer to open your site and create following folder structure inside “SiteAssets” library – “/SiteAssets/Resources/Utilities/AnnouncementTicker” and create following three files inside the “AnnouncementTicker” folder:

  • AnnouncementTicker.html
  • AnnouncementTicker.js
  • AnnouncementTicker.css

The code of the files are given below on this article. Please note that you have to download Bootstrap and JQuery plugin file(s) and add to the “Resources” folder as shown in the code.  Once you have the files ready add a “Content Editor WebPart” in the appropriate place and add reference to the “AnnouncementTicker.html” file in the content editor web part and you get the ticker functionality like below:


Clicking on the “More…” button will display the announcement details in a bootstrap modal like below:











<divclass=”alert alert-info alert-dismissible announcementAlerts”role=”alert”>




<spanclass=”badge badge-info bAnnouncement”><iclass=”glyphicon glyphicon-volume-up”></i></span><strong>Announcements!</strong>







<buttontype=”button”class=”close”data-dismiss=”alert”style=”top:-55px; vertical-align:top;text-align:right;”>




<divclass=”modal fade”id=”announcementDetail”tabindex=”-1″role=”dialog”aria-hidden=”true”>




<buttontype=”button”class=”close hidden”data-dismiss=”modal”aria-label=”Close”><spanaria-hidden=”true”>&times;</span></button>





<buttontype=”button”class=”btn btn-warning”data-dismiss=”modal”><iclass=”glyphicon glyphicon-remove-circle”></i> Close</button>









$(document).ready(function () {LoadAnnouncements();});function LoadAnnouncements() {var clientContext = new SP.ClientContext.get_current();var oList = clientContext.get_web().get_lists().getByTitle(‘Announcements’);var camlQuery = new SP.CamlQuery();


var camlQueryText = “<View>” +

“<Query>” +

“<Where>” +

“<And>” +

“<Leq>” +

“<FieldRef Name=’PublishingStartDateTime’ />” +

“<Value IncludeTimeValue=’TRUE’ Type=’DateTime’><Today /></Value>” +

“</Leq>” +

“<Geq>” +

“<FieldRef Name=’Expires’ />” +

“<Value IncludeTimeValue=’TRUE’ Type=’DateTime’><Today /></Value>” +

“</Geq>” +

“</And>” +

“</Where>” +

“<OrderBy>” +

“<FieldRef Name=’Modified’ Ascending=’False’ />” +

“</OrderBy>” +

“</Query>” +



this.collAnnouncementListItems = oList.getItems(camlQuery);



Function.createDelegate(this, this.onAnnouncementQuerySucceeded),

Function.createDelegate(this, this.onQueryFailed)



function onAnnouncementQuerySucceeded(sender, args) {

var announcementCount = collAnnouncementListItems.get_count();

if (announcementCount > 0) {

var listItemInfo = ”;

var listItemEnumerator = collAnnouncementListItems.getEnumerator();

var announcementHTML = “”;

var annDlgTitle = “”;

var annDlgBody = “”;

while (listItemEnumerator.moveNext()) {

var oListItem = listItemEnumerator.get_current();

var announcementID = oListItem.get_item(‘ID’);

var announcementTitle = oListItem.get_item(‘Title’);

var announcementBody = oListItem.get_item(‘Body’);

var announcementExternalLink = “”;

if (oListItem.get_item(‘ExternalLink’) != null) {

announcementExternalLink = oListItem.get_item(‘ExternalLink’).get_url();


var pubSDT = $.date(oListItem.get_item(‘PublishingStartDateTime’));

annDlgTitle += ‘<span id=”annDlgTitle’ + announcementID + ‘”><h3 class=”annDlgTitle”><span class=”label label-info”><i class=”glyphicon glyphicon-calendar”></i> ‘ + pubSDT + ‘</span> – ‘ + announcementTitle + ‘</h3></span>’;

annDlgBody += ‘<div id=”annDlgBody’ + announcementID + ‘”>’ + announcementBody + ‘</div>’;

announcementHTML += ‘<li><span class=”label label-info”><i class=”glyphicon glyphicon-calendar”></i> ‘ + pubSDT + ‘</span> – <span class=”AnnTitle”>’ + announcementTitle + ‘ <button data-externallink=”‘ + announcementExternalLink + ‘” onclick=”javascript:OpenAnnouncementDetails(‘ + announcementID + ‘, this);” type=”button” class=”btn btn-xs btn-primary”><i class=”glyphicon glyphicon-fullscreen”></i> More…</button></span></li>’;





setInterval(function () { RotateAnnouncement() }, 5000);



function RotateAnnouncement() {

$(‘#AnnouncementTicker li:first’).slideUp(function () { $(this).appendTo($(‘#AnnouncementTicker’)).slideDown(); });


function onQueryFailed(sender, args) {

alert(‘Request failed. ‘ + args.get_message() +

‘n’ + args.get_stackTrace());


function OpenAnnouncementDetails(itemID, moreBtn) {

$(“[id*=annDlgTitle]”).each(function (i) {

$(this).css(‘display’, ‘none’);


$(“[id*=annDlgBody]”).each(function (i) {

$(this).css(‘display’, ‘none’);


$(“#annDlgTitle” + itemID).css(‘display’, ”);

$(“#annDlgBody” + itemID).css(‘display’, ”);


keyboard: false


if ($(moreBtn).attr(‘data-externallink’) != “”) {

setTimeout(function () { window.open($(moreBtn).attr(‘data-externallink’), ‘AnnouncemwntWindow’, ‘status=1,toolbar=0,resizable=1,scrollbars=1’); }, 500);




$.date = function (dateObject) {

var m_names = new Array(“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”);

var d = new Date(dateObject);

var day = d.getDate();

var month = m_names[d.getMonth()];

var year = d.getFullYear();

if (day < 10) {

day = “0” + day;


var date = month + ” ” + day + “, ” + year;

return date;



.AnnouncementAlerts {height: 60px;}#AnnouncementTicker {height: 60px;overflow: hidden;list-style: none!important;


padding: 0px;

margin: 0px!important;

padding-left: 10px;

vertical-align: top;


#AnnouncementTickerli {

height: 60px;

list-style: none!important;

padding: 0px!important;

margin: 0px!important;

vertical-align: top;


.AnnouncementLabel {

list-style: none!important;

padding: 0px!important;

margin: 0px!important;

vertical-align: top;


.AnnDate {

font-style: italic;

font-size: 13px;


.AnnTitle {

padding-left: 0px;

font-size: 14px;

color: black;


.bAnnouncement {

font-size: inherit!important;


.badge-info {

background-color: #3a87ad;


.annDlgTitle {

margin-top: 0px!important;

margin-bottom: 0px!important;


.AnnTitleLink {

font-weight: bold;


Sandip Paul

About Sandip Paul

Sandip Paul is a Technical Architect at Netwoven based in the bay area. He has over 13 years of experience in software development and consulting working with both large and small customers. He is experienced in all the three Microsoft clouds: Office 365, Dynamics 365 and Azure.

Sandip has worked with Netwoven for over 10 years building scalable systems using Microsoft technologies. He specializes in design and implementation of SharePoint, .NET, and Frontend technologies.

Sandip holds a Bachelor of Technology degree in Computer Science from West Bengal University of Technology, Kolkata.


Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here :