Posts

Showing posts from 2016

“Pause until Date” workflows handle changing dates

Image
SharePoint workflow update 'pause until date' when item is updated In some cases we need to update the 'pause until date' dynamically from the SharePoint designer workflow. In my case I have a list, that contains Expire Date. I need to send remainder before 7 days. But here there is a difficulty, suppose users update the 'Expire date' then 'Remainder date'(ie workflow 'pause until date') also get updated in workflow. But SharePoint workflow will not start if there is a running workflow instance for that item. It is difficult to stop the running workflow OR update the pause until date' while it is running. To handle this scenario we can use SharePoint 2013 workflow. SharePoint 2013 workflow contains a new feature called 'Loop'. We can use this loop until our condition satisfied. So that we can update the 'pause until date' inside the loop dynamically. To test this workflow we can log some test messages inside the w

jquery callback methods for asynchronous loop to finish

Some times jquery loop statement will not wait until the ajax call completion. For this case we can use the jquery callback method for looping ajax calls. In the below example arrayValue is passed into a call back function. this function will  be executed until we call the 'callback()' (which is called in the else part). we need to write this function inside a function. function parentFunction() { var deferred = $.Deferred(); (function Task(i,callback) { if(i<arrayValue.length) {  /*your code here*/ var temp = yourFunctionCall(arrayValue[i]);  temp.done(function() { Task(i+1,callback) }) } else { //this call will terminate the function callback(); } }) (0,function(){alert('Completed');deferred.resolve();}); return deferred.promise();  } Please refer the following links for more details  Link1  ,  Link2

Get all user names instead of User ID from a List using Rest API SharePoint 2013

Use the below code to get user name directly from a list instead of getting a user ID. Using $expand OData operator you can specify that the request returns projected fields from other lists and the values of lookups. function getAllUserNames() { var deferred = $.Deferred(); var arrayContractOwner = new Array(); // this array to get all user names from list     var serverUrl = _spPageContextInfo.webAbsoluteUrl;     var ListNameUrl = String.format("{0}/_api/web/lists/getbytitle('ListName')/items?$select=UserColumnName/Name,UserColumnName/Title&$expand=UserColumnName/Id",serverUrl);                       $.ajax({                     url: ListNameUrl,                     type: "GET",                     headers: {"Accept": "application/json;odata=verbose"},                     cache:false,                                   success: function(data)                     {                       var test = data;        

Get Login Name and Display Name by User ID using SharePoint 2013 REST API

We can pass the user id to the below function & we can get the user name. function getUser(id){ var returnValue;   jQuery.ajax({    url: "http://YourSite/_api/Web/GetUserById(" + id + ")",    type: "GET",    headers: { "Accept": "application/json;odata=verbose" },    success: function(data) {            var dataResults = data.d;       //get login name       var loginName  = dataResults.LoginName.split('|')[1];       alert(loginName);         //get display name       alert(dataResults.Title);    }  }); } Please refer this link for more details  Link1

Auto Complete Textbox in Jquery

Image
HTML & Jquery code: <html> <head>                 <script src=" https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js "></script>                 <script src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js "></script>                 <link href=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css " rel="stylesheet"/>                 <script>                 $(document).ready(function(){                                 var carName = new Array();                                 carName.push("Volvo");                                 carName.push("Saab");                                 carName.push("Mercedes");                                 carName.push("Audi");                                 $('#txtName').autocomplete({source :carName});

Ajax Loader

Image
To display loading symbol while ajax call, you can use the below code. Content Editor Code: <link href=" https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css " rel="stylesheet"/> <script src=" https://code.jquery.com/jquery-1.10.2.js "></script> <script src=" https://code.jquery.com/ui/1.10.4/jquery-ui.js "></script> <link href="/sites/<sitename>/SiteAssets/CSS/Style.css" rel="stylesheet" type="text/css"/> <script src=" /sites/<sitename> /SiteAssets/Scripts/Test.js"></script>   <div class="modal" id="modalDiv">&#160;</div> Style.css Code: .modal {     display:    none;     position:   fixed;     z-index:    1000;     top:        0;     left:       0;     height:     100%;     width:      100%;     background: rgba( 255, 255, 255, .8 )         url(' /si

jquery popup window Example

Image
Save the below code as a html file & open with IE or any browser. HTML & Jquery Code: <html>                 <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>          <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script> <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css" rel="stylesheet"/>  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"/> <script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script&

jquery.dataTables Example

Image
Save the below code as a html file & open with IE or any browser. HTML & JS Code To use this Jquery datatable we need to use <thead> and <tbody> tags & number of <td> columns also should be same in thead and tbody tags. <html>      <head>        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>        <!--        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>      <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css" rel="stylesheet"/> -->        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"/>          <script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>  

PeoplePicker get & Update List item using Rest API in SharePoint 2013

Image
When you try to create/update list item just check the fields details of the list using the REST API. for an example I have created a List named  TestList . Following is the field details: Title:  Text TestColumn1:  Text Text Column 2:  Text Test Column 3:  People and Group Now to check the field details and check the details of the fields using the following REST API URL: http : //SITEURL/_vti_bin/client.svc/web/lists/getByTitle('TestList')/items Now you will get following data in IE Or Chrome:  Find your column name from the XML page. Now check the above picture carefully, the userid needs to be saved in the  TestColumn3Id  column not in the  TestColumn3 . Now check the following code: Go To  SiteAssets and add   RestPeoplePicke .js  Open any page & Insert content editor webpart. Include the below code in Content Editor. //Code for content editor: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&quo