Posts

Showing posts from May, 2016

Get People picker properties on client side

Some times you need to get user name from people picker for sending mails, comparing to other fields , displaying some where. Below is the few tricks that are useful to get name, and other user properties from picker. Below is the simplest way to get user name from picker. $('div[title=PeoplePickerDivTitle] span span span').text() And the below is the use full to get people picker properties email, user id ..etc var userdetails = JSON.parse($('input[ID^=PeoplePickerDivStartID][ID$=HiddenInput]').val()) if(userdetails[0]){       var displayname = userdetails[0].DisplayText Var email = userdetails[0].EntityData['Email'] } above script parse the people picker hidden input data which contains user values into JSON, and will get all user properties that exists in people picker control.

Get Query String from SharePoint page

There were several JavaScript  techniques to get query strings from URL, following are the few techniques are inbuilt in SharePoint. The main aim of this article is to use inbuilt SharePoint script techniques and to get rid of writing own JavaScript logic on every time. 1.    GetUrlKeyValue GetUrlKeyValue is an inbuilt JavaScript method exists in every page, you required to pass parameter to get the query string. You get query sting from a current url or from any url that passed as parameter to the method. It accepts a string as query string, bool for encoded value and a custom url. var itemID =  GetUrlKeyValue('ID'); var itemSourc =  GetUrlKeyValue('Source'); var enSournce = GetUrlKeyValue('Source',true);                // encoded result var enSournce = GetUrlKeyValue('Source',false);                // decoded result var cId = GetUrlKeyValue('ID',false,'www.xyz.com?ID=2'); 2. JSRequest JSRequest is an inbuilt method used t