Recursive JSON de-serialization in JavaScript

December 26, 2014

I’ve been working on a project using WCF and Entity Framework for data access and JavaScript for the client-side. I had several problems with recursive JSON de-serialization in JavaScript trying to render the objects returned from the services. I kept ending up with these “$ref” properties that are actually references to other objects in the array. This was of no use to me when trying to render the items into a table using any of the rending engines (currently using DataTables). What now? After Googling, trying and failing, I found out that the JSON-js project has an answer: cycle.js. The comments state: //...
no comments

SharePoint 2013 Workflows get Suspended (Error 500)

July 7, 2014

A client asked me to investigate an issue where SharePoint 2013 Workflows get Suspended (Error 500). The workflows were triggered manually or automatically with the same result every time: 2 minutes are they start, they get the “Suspended” status. When you look at an item’s workflows, you can see this blue icon. Click on it to see the error message: Looking through log files did not help much, because the error was not mentioned and there was no correlation ID to go wit it. We tried installing SP1 (the newer one) and the latest June 2014 CU, but these did not resolve...
no comments

Creating a Publishing Page in SharePoint using JavaScript

June 22, 2014

I was tasked with creating a Publishing Page in SharePoint using JavaScript (JSOM), and found it wasn’t an easy task. Looking through forums, blogs and other publications, I could not find a hint as to how to accomplish this task, and has to use bits and pieces (as well as my own knowledge) to build the solution. The requirement is this: create a publishing page based on a specific page layout. The solutions requires 2 major steps: 1. Get the required page layout 2. Create the page using the page layout The code relies on an article in MSDN - SharePoint 2013: Create publishing...

Display the Files Ribbon Tab When Checking a Document (SharePoint)

May 28, 2014

I was asked to display the Files ribbon tab when checking a document in SharePoint in a document library list view, meaning: when a user checks the checkbox next to a document, automatically pop out the file-related operations. My first question was: “is doesn’t work this way already!?” Anyway, I got to work and a check list: Figure out how to popup ribbon groups Figure out how to get the list type Do what the client asked me to do – show the ribbon on click Popup Ribbon Tabs Some research let me to figuring out there are 2 methods available to accomplish the task, and...

SharePoint Ribbon Button to Check-out, modify a value and Check-in

May 23, 2014

I was tasked with creating a SharePoint ribbon button to checkout, modify a value and check-in a document in a document library. There’s a pretty straight forward approach to do this, but it get complicated when you need to work with several items. That’s were the asynchronous calls get tangled and you lose a file. Working with JSOM you can execute executeQueryAsync to execute loading and query requests. When dealing with multiple items, you need to make sure all requests have been finished before refreshing the page or redirecting to another page. There are 2 approaches to doing so. The...
no comments

Using REST and JavaScript to load Taxonomy values in SharePoint 2013

May 7, 2014

Using REST and JavaScript to load Taxonomy values in SharePoint 2013 proved a tad difficult. Apparently using REST doesn’t provide you with the actual (Label) you see in the list item. You get the term’s GUID which doesn’t get you very far…. All I wanted was load distinct taxonomy values from a list. Sounds pretty straight forward, doesn’t it? Well, there some limitations when working with REST and taxonomy fields. You cannot get the label value (actual text shown in the list) nor can you filter a taxonomy field. This makes the assignment so much harder. An example of a taxonomy field’s...

Birthdays using on SharePoint 2013 REST, jQuery promise and Bootstrap

March 24, 2014

Over the years, I’ve been asked to build a web part displayed user’s birthdays many times. Every one was a little different. Some used a list, some used the user profile service and some used external data sources. I have always wanted to build a customizable one that support all options, but it was never cost effective. I’ve decided to write a blog post illustrating one of the solutions I came up with to the requirement. Here's a solution for displaying a list of employee Birthdays using on SharePoint 2013 REST, jQuery promise and Bootstrap. The data is retrieved from...

ASP.NET FileUpload custom buttons not working on IE8

January 15, 2014

Apparently, ASP.NET FileUpload custom buttons not working on IE8. Meaning that if you add a custom button that triggers the click event for the FileUpload input, the browse for file opens, the filename is displayed, but the file is not posted back to the server. IE8 is remarkable that way. The requirement was building a file upload mechanism with a custom design that will work on IE8+, Chrome and FireFox. The design is as follows (sorry for Hebrew captions): Where: 1 – The “browse” button that opens the “Browse for file” dialog 2  - The textbox that displays the select file’s name 3 – The...
no comments

Button doesn’t fire the Click Event in SharePoint

January 14, 2014

I was asked to build an application page with a FileUpload control. After implementing the code, I was startled to find that SharePoint interferes with the Click event in Internet Explorer. As as result the button doesn't fire the Click event in SharePoint, which requires the user to click on the upload button twice before actually posting the page. Apparently this is a common problem that has something to do with the way SharePoint's client-side code modifies some of the event handling functions for elements on the page. I could not figure out why or how this happens, so I decided a...
no comments

Save an Offline Copy of your HTML page

January 1, 2014

A client asked me to save a “hard” copy of a form once it’s submitted into the system. So obviously I looked into exporting images and PDF.I came across this interesting project: wkhtmltopdf - Convert html to pdf using webkit (qtwebkit), but I could not use due to the client’s restrictions. Then it occurred to me that all I need is the HTML.jQuery knows how to get me that HTML… After searching a bit, I found this command: $('*').html(); This command gets you the entire webpage including the head, body, scripts and styles.Only thing left to do is...
no comments