Populate Current Loggedin User in People Picker

In one of my project we need populate current logged in user in People Picker by default. I have implemented below code to do it.

Add 1.7.2.jquery.min.js and jquery.SPServices-2014.02.min.js file in the master page or page level.

 
$(document).ready(function() { 
 ExecuteOrDelayUntilScriptLoaded(loadCurrentUser, "sp.js"); 
});

function loadCurrentUser() { 
 var userName = $().SPServices.SPGetCurrentUser({ fieldName: "UserName", debug: false});
 $('h3:contains("PeoplePickerFieldName")').closest('tr').find('div[title="People Picker"]').html(userName);
 $('img[title="Check Names"]').trigger('click'); 
} 

** Replace “PeoplePickerFieldName” with your people picker field name.

** Replace “userName” with your desired user’s user name to add other user in peoplepicker.

Let me know if you face any challenges.

Happy Coding.. ūüôā

Regards, Jay Doshi

Invalid characters in SharePoint naming conventions

This article lists the characters that you cannot use in the following names in Microsoft SharePoint:

  • Site names
  • Folder name
  • Server names
  • File names

Site names, subsite names, or site group names

  • You cannot use the following characters anywhere in a site name, in a subsite name, or in a site or Active Directory group name:-
    • Tilde (~)
    • Number sign (#)
    • Percent (%)
    • Ampersand (&)
    • Asterisk (*)
    • Braces ({ })
    • Backslash (\)
    • Colon (:)
    • Angle brackets ([ ])
    • Question mark (?)
    • Slash (/)
    • Plus sign (+)
    • Pipe (|)
    • Quotation mark (‚Äú)
  • You cannot start a site name, a subsite name, or a site group name with an underscore (_) character or with the period (.) character.
  • When you create a site name, a subsite name, or a site group name, you cannot use strings that were already used to name managed paths.
  • You cannot use the period character consecutively in the middle of a site name, a subsite name, or a site group name.
  • You cannot use the period character at the end of a site name, a subsite name, or a site group name.

Folder names

  • You cannot use the following characters anywhere in a folder name or a server name:
    • Tilde
    • Number sign
    • Percent
    • Ampersand
    • Asterisk
    • Braces
    • Backslash
    • Colon
    • Angle brackets
    • Question mark
    • Slash
    • Pipe
    • Quotation mark
  • You cannot use the period character consecutively in the middle of a folder name.
  • You cannot use the period character at the end of a folder name.
  • You cannot start a folder name with a period character.

File names

  • You cannot use the following characters anywhere in a file name:
    • Tilde
    • Number sign
    • Percent
    • Ampersand
    • Asterisk
    • Braces
    • Backslash
    • Colon
    • Angle brackets
    • Question mark
    • Slash
    • Pipe
    • Quotation mark
  • You cannot use the period character consecutively in the middle of a file name.
  • You cannot use the period character at the end of a file name.
  • You cannot start a file name by using the period character.
  • In addition, file names and folder names may not end with any of the following strings:
    • .files
    • _files
    • -Dateien
    • _fichiers
    • _bestanden
    • _file
    • _archivos
    • -filer
    • _tiedostot
    • _pliki
    • _soubory
    • _elemei
    • _ficheiros
    • _arquivos
    • _dosyalar
    • _datoteke
    • _fitxers
    • _failid
    • _fails
    • _bylos
    • _fajlovi
    • _fitxategiak

How to change Default Home Page : SharePoint

I frequently get questions on changing the home page or using another page as the home page:

  • Can I have three (or four or five or‚Ķ) columns in the default home page?
  • Do I have to use the new wiki home page in my Team Site?
  • I want to test a new home page design, but I don‚Äôt want to lose the existing home page‚Ķ (just in case you know‚Ķ)
  • How can I use a page from my wiki library as my home page?

Below are four ways to set another page as your home page: (all four work for both 2007 and 2010)

  • From Site Settings (If the publishing features are enabled)
  • From SharePoint Designer
  • From code / API
  • From PowerShell

The first two can be used by Site Owners, the second two can only be used for developers and administrators

Important Notes for all methods:
Make sure all of your users have at least read access to the new home page, and if in a library that you have it checked in and published.

1.   If the Publishing features are enabled for a site then: (From Site Settings)

Click on Site Action  =>  Site Setting  =>  Welcome Page

Image

2.   From SharePoint Designer:

Right-click the new page and click “Set as Home Page”.¬† (For SharePoint 2007 this only appears to work from SharePoint ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†Designer if the file is in the root of the site. I.e. the same place as default.aspx.)

Image

3. From Code / API

Please follow the following link for code.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage.aspx

4. Via PowerShell

$site = Get-SPSite http://yourserver/sites/yoursite
$web = $site.RootWeb (or $web = $site.OpenWeb("yoursubsite") 
$folder = $web.RootFolder 
$folder.WelcomePage = "SitePages/home.aspx" 
(or $folder.WelcomePage = "default.aspx") 
(or $folder.WelcomePage = "Shared%20Documents/mycustomwebpartpage.aspx") 
$folder.update() 
$web.Dispose() 
$site.Dispose()

If you need any type of help please let me know on following email id : jaydoshi.com@gmail.com. Thank You.

How Value Return in Before Properties, After Properties and ListItem using EventReceiver in SharePoint2010

Event receivers are common in SharePoint development so its better to understand the data available in each events. Sometimes as a developer we jump into coding before thinking about contextual data availability.One more important thing to notice list event receiver  and document library event receiver are different items of contextual data availability.Following Table will give you a clear picture about the contextual data in each events.

  • SharePoint List

Event

Before Properties Returns

After Properties Returns

ListItem Returns

Event Type

Item Adding

Null Value

New Value

Null Value

Synchronous

Item Updated

Null Value

New Value

New Value

Asynchronous

Item Updating

Null Value

Changed Value

Current Value

Synchronous

Item Updated

Null Value

Changed Value

New Value

Asynchronous

Item Deleting

Null Value

Null Value

Current Value

Synchronous

Item Deleted

Null Value

Null Value

Null Value

Asynchronous

  • SharePoint Document Library

Event

Before Properties Returns

After Properties Returns

ListItem Returns

Event Type

Item Adding

Null Value

Null Value

Null Value

Synchronous

Item Updated

Null Value

Null Value

New Value

Asynchronous

Item Updating

Current Value

Changed Value

Current Value

Synchronous

Item Updated

Current Value

Changed Value

New Value

Asynchronous

Item Deleting

Null Value

Null Value

Current Value

Synchronous

Item Deleted

Null Value

Null Value

Null Value

Asynchronous

How to hide fields based in selection of radio button using java script

SharePoint generates a HTML code for the New/Edit/Display Page for each created list.

Now you have to the following java script code in your desire page to hide the field

Assume the html code is as follow:

<input type="radio" name="Internal Person" id="Person Type" value="ctl001">Internal Person</input> 
<input type="radio" name="External Person" id="Person Type" value="ctl002" >Invoiced</input>
The above code displays 2 radio button. Now you want to hide
var newVal = $(':radio[name=Reported By]:checked').val();
if (newVal == "ctl001") 
{
       $('nobr:contains("Internal Reporter Name")').closest('tr').show(); 
       $('nobr:contains("External Reporter Name")').closest('tr').hide(); 
}
else
{
       $('nobr:contains("Internal Reporter Name")').closest('tr').hide(); 
       $('nobr:contains("External Reporter Name")').closest('tr').show();             
}

Getting error while creating a new web app saying “The password supplied with the domainname\username was not correct. Verify that it was entered correctly and try again”

When you create new web application at that time you enter your credential as the system account of the particular Web Application.

After that when you update your credential at that time you must have to update your credential in SharePoint also because SharePoint store your credential in SharePoint database.

To update your credential in SharePoint Database you must have to pass follow command in command prompt:

** Please open command prompt in Administrator mode.

  1. cd “C:\Program Files\Common Files\Microsoft Shared\Web Server¬†Extensions\14\BIN” and press enter.
  2. stsadm -o updatefarmcredentials -userlogin¬†<domain\username>¬†–password¬†<newpassword>

Once you update your credential in SharePoint database it will not effected directly so that you need to restart you IIS Web Server. For that following command will be fire in command prompt.

  1. iisreset /stop
  2. iisreset /start