Sunday, December 18, 2016

Install Node.js without admin rights

Hi Folks,
This is a copy paste version of one of the blogs which helped me.Giving due to credit to him.Just wanted a copy of the same with some minor updates.Below is the link for reference

Step 1: Get Node.exe
First you will need to download the Windows Binary. You can get it from Node.js download page or For x64, you will have to download from the appropriate folder. Move the executable to a local folder.
Step 2: Get NPM
NPM (Node Package Manager) is the package manager for Node.js and you will need this for your development. You can download NPM from and extract the zip file to a local folder.
Step 3: Copy the extracted files in a folder
Copy npm.cmd from extracted folder \npm\bin to the folder where node.exe resides
Now move the extracted npm files in a folder named "node_modules\npm" in the same folder where node.exe resides.
Such that the structure become like this
node (Folder)
|--------- node.exe
|-------- npm.cmd
|--------- node_modules (Folder, copied from the extracted zip) 
               |----- npm
                         |---- bin (extracted files)
                            ..... (extracted files)

Step 4: Configure the environment PATH variable.
You need to set up the PATH variable so that you can call node from anywhere in the system.
set PATH=%PATH%;D:\path-to-your-node;D:\path-to-your-npm
Mostly likely, the usual way of setting environment variables may not be accessible or not sufficient for you. instead you might want to hit Win + R (Open the Run dialog) and execute this:
rundll32 sysdm.cpl,EditEnvironmentVariables
This command will provide you with Environment Variables dialog box. You will be able to add/modify the PATH variable for the current user.
Step 4: Testing your Node.js installation
Quick way to test your Node.js installation is to get the version of Node.js that you are running by running the following command:
node --version

Extra: Setting up NPM to work behind a proxy
Apart from the hurdle of not having admin rights, one common issue is working behind the corporate proxy. Fire up your command line and type in the following:
npm config set proxy http://proxy:port
npm config set https-proxy https://proxy:port
If you need to specify the credentials, then use the following syntax:
npm config set proxy http://username:password@proxy:port
npm config set https-proxy https://username:password@proxy:port

Thursday, October 27, 2016

Creating custom events for a control in HTML

Hi All,

Sometimes we need to create a custom event for a control which we can use it to get the context of the control.Below is a quick method using jQuery to do that.

In the below example i have created an init method for input tag.

This method can be simply trigger using  


 <input id="txtName" class="news" init="initializeSection1" />

    <input id="txtName" class="news" init="initializeSection2" />

        $(document).ready(function () {

            $(".news").bind("init", function (e, data, val) {
                var initializeFunctionName = $(this).attr("init");
                window[initializeFunctionName](e, data, val);



        function initializeSection1(e, data, val) {

            alert("I called initializeSection1");
            var parentObj = $(e.currentTarget).parent()

        function initializeSection2(e, data, val) {

            alert("I called initializeSection2");
            var parentObj = $(e.currentTarget).parent()


Tuesday, October 18, 2016

SharePoint 2016, 2013 , 2010 , 2007 Create list item with existing ID

Hey Guys,

Now i was in a really tricky scenario where a master record had been deleted by someone which was referenced using code in numerous places. Changing the code would be a nightmare.
Now the easiest solution which will come to everyones mind is to add the list item with those possible values again. But it would not retain the ID value which was used in the code.Let me give you an example to clarify the problem statement

There is a “status” master list with the following values and the third list item is deleted.
We want the 3rd list item with ID=3 to be restored even when it is deleted from recycle bin as in the code the ID column is used to reference the status.

In Draft

Now usually the answers would be

  1.   Restore it from recycle bin (almost 3 months have passed and it has been deleted from recycle bin as well)
  2.   Delete the list and recreate the list with fresh entries (Break referential integrity of lists where the column from this list is looked up i.e lookup )
  3. It cannot be done.ID is auto increment column (Sad to head but its true)

So, last option would be to change the code L
This would result in enormous effort of code changing.
But wait if even you face similar scenario and have lesser amount of records (say 10-15 records) which have to be recovered then there is a savior
Follow below steps to recover your item

  1. Create a replica of the list where the item is to be recovered
  2. Add all the items in the order required.
  3.   Navigate to site manager using below url
  4. http://<web level url>/_layouts/sitemanager.aspx
  5. Select the replica list in left navigation then list items will appear in right pane.
  6. Select the list item from replica list and select Actions >> Copy

  7.  Then in the copy dialog select the original list where the item was deleted.
  8.   Done

Note: This method can be used only when the item is deleted from recycle bin as well.If the item of same is present in recycle then it would not recreate with same ID.

Tuesday, September 27, 2016

Angular JS Table with Paging , GroupBy and Search

Some of the common syntax which are most often used while working on Angular js

Application Name :
ID Application Name
{{childRow.Id}} {{childRow.ApplicationName}}

Get Workflow History using Workflow.asmx SharePoint 2010

Sometimes we need to display workflow history based on the item id of the list item.

Below is the code which will help you to get that.

Date Occured
<script src="" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script src=""></script>


    $(document).ready(function () {

        ExecuteOrDelayUntilScriptLoaded(getHistory, "sp.js");

    function getHistory() {

        var promoItemID = getParameterByName("promoid");

        getPromotionItem(promoItemID).done(function (historyItem) {

            var itemUrl = window.location.hostname + historyItem.get_item("FileRef");

            getWorklfowData(itemUrl).done(function (workflowInstanceIds) {

                var workflowHistoryData = getWorkflowDataByInstanceIds(workflowInstanceIds);





    function getWorkflowDataByInstanceIds(workflowInstanceIds) {
        var workflowData = [];

        $(workflowInstanceIds).each(function () {

            var wfInstanceID = this;

            var url = window.location.origin + _spPageContextInfo.webServerRelativeUrl + "/_vti_bin/listdata.svc/EPMAHistory?$filter=WorkflowHistoryParentInstance eq '{" + wfInstanceID + "}'&$top=50&$expand=UserID&$select=UserID/Name,Outcome,UserID,DateOccurred,Duration,Description,ActualDurationDHM"
                type: "GET",
                dataType: "json",
                async: false,
                url: url,
                success: function (data) {

                    if (data.d.length > 0) {

                        for (var i = 0; i < data.d.length ; i++) {
                            var result = data.d[i];

                            var workFlowData = {};
                            workFlowData.Outcome = result.Outcome;
                            workFlowData.Userid = result.UserID;
                            workFlowData.DateOccured = Date(result.DateOccurred);
                            workFlowData.Duration = result.ActualDurationDHM;
                            workFlowData.Description = result.Description;


                error: function (jqXHR, exception) {

                    console.log("Error " + jqXHR.responseText);



        return workflowData;


    function getPromotionItem(promoItemID) {
        var d = $.Deferred();

        var clientContext = SP.ClientContext.get_current();
        var promotionList = clientContext.get_web().get_lists().getByTitle('Promotions');

        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' +
                                                        '<Value Type=\'Number\'>' + promoItemID + '</Value>' +
                                                  '</Eq></Where></Query>' +

        var collListItem = promotionList.getItems(camlQuery);


        clientContext.executeQueryAsync(function (clientContext) {

            var collEnumerator = collListItem.getEnumerator();
            var historyItem;
            while (collEnumerator.moveNext()) {
                historyItem = collEnumerator.get_current();


        }, function (sender, args) {

            console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


        return d.promise();


    function generateTable(historyRecords) {

        var tblHead = "<table><tr>" +
                                    "<td class='ms-vh2'  >Outcome</td>"
                                    + "<td class='ms-vh2' >User ID</td>"
                                    + "<td class='ms-vh2' >Date Occured</td>"
                                    + "<td class='ms-vh2' >Actual Duration</td>"
                                    + "<td class='ms-vh2' >Description</td>"
                            + "</tr>";
        var tblBody = "";
        var tblFooter = "</table>";

        $(historyRecords).each(function () {
            tblBody += "<tr><td class='ms-vb2'>" +
                             + "" + this.Outcome + "</td>"
                             + "<td class='ms-vb2'>" + this.Userid.Name + "</td>"
                              + "<td class='ms-vb2' >" + this.DateOccured + "</td>"
                            + "<td class='ms-vb2'>" + this.Duration + "</td>"
                            + "<td class='ms-vb2'>" + this.Description + "</td>"
+ "</tr>"


        var tblHTML = tblHead + tblBody + tblFooter;

    function getWorklfowData(itemUrl) {
        var d = $.Deferred();
        var soap = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
        "<soap:Envelope xmlns:xsi=\"\" " +
            "xmlns:xsd=\"\" " +
            "xmlns:soap=\"\"> " +
          "<soap:Body> " +
            "<GetWorkflowDataForItem  xmlns=\"\">" +
                "<item>" + itemUrl + "</item>" +
            "</GetWorkflowDataForItem> " +
          "</soap:Body>" +

            url: "",
            beforeSend: function (xhr) {
            type: "POST",
            dataType: "xml",
            data: soap,
            complete: function (msg) {

                var workflowInstanceIds = getInstanceIDbyResponse(msg.responseXML);

            contentType: "text/xml; charset=utf-8"

        return d.promise();

    function getInstanceIDbyResponse(responseXML) {

        var workflowInstanceIds = [];
        $(responseXML).find("ActiveWorkflowsData > Workflows > Workflow").each(function () {
            var thisStatus = $(this).attr("Status1");

            // Only show workflows which are currently In Progress (Status1 = 2)
            if (thisStatus == "2") {
                var thisTaskListId = $(this).attr("TaskListId");
                var thisTemplateId = $(this).attr("TemplateId");

            var thisInstanceId = $(this).attr("Id");


        return workflowInstanceIds;


    /*Utility Methods*/

    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));


<div id="dvHistoryView">


Thursday, September 1, 2016

SharePoint 2010 Calculated field value using ID column to generate an auto number

Hi All,

Sometimes we need to use the id column to generate an autogenerate number like INC0000332 etc.

Below formula can be used to create such a column.


Note: The item should be saved in order to reflect the value in the column.

Sunday, August 28, 2016

SharePoint 2010 List View Header Count of Rows

Hi All,

Sometimes we need to show the number of rows in the header itself when we have created an accordion on the webpart header.below is the code which helps us display count of the rows.


var countOfRows=   $(this).find(".ms-listviewtable").find("tr .ms-vb2:first-child").length;

  $(this).find(".ms-WPTitle a span:first-child").append("<b> (" + countOfRows + ")</b>");


Edit: ID column is needed in the list view to display the count.Working on it so that this can be eliminated.