Monday, May 27, 2013

How To Set File Uplod Limit In SharePoint2010

By Default SharePoint2010 provides 50MB files to be upload to the server. If you want to extend upload size to server then you can do it in two ways.




  1. Through Central Admin: Navigate Central Admin -> Application Management -> Manage Web Application -> Select your web application -> General Setting. It contains Maximum Upload Size. Configure this to set maximum upload file limit. But you have to take care about the maxAllowedContentLength and maxRequestLength from the web.config file. To update web.config its very harmful if any other changes done in web.config so i preferred you use following command to set maximum upload file size.

  2. Using a SharePoint Management Shell: Open SharePoint Management Shell with Admin rights and fire the following command.



stsadm -o setproperty -propertyname max-file-post-size -propertyvalue <max-file-size (MB)> [-url http://server_name]


This command will configure your site as you mention the size in -propertyvalue.

Saturday, May 25, 2013

Create New Site Collection in the New Content Database in SharePoint2010

If you want to create a new site collection in the specific database, there are several different options available in the SharePoint 2010.

From the central administration site, you can create the site collection in the specific database with the following workaround. The downside of this approach is you have to temporarily take down the all the content databases in the given web application except the database where you want to create the new site collection.

  • Create a new content database for the given web application (Central Administration -> Manage Content Databases)

  • Detach/remove the content databases except the new one (Central Administration -> Manage Content Databases)

  • Create the new site collection from the central admin (Central Administration -> Create Site Collection)

  • Attach/Add the offline content databases (Central Administration -> Manage Content Databases)


Better way to approach creating the new site collection in the specific content database is to use New-SPContentDatabase and New-SPSite PowerShell commands.

  • Step 1- Add New Content DB to the Web Application


New-SPContentDatabase -Name WSS_Content_Accounts -WebApplication     http://demosite:55555


  • Step 2- Create New Site Collection with Top Level Site Based on Team Site Template in the New Content DB


New-SPSite http://demosite:55555/sites/accounts -OwnerAlias “Jaydoshi\Administrator” -ContentDatabase WSS_Content_Accounts -Name “Account Sites” -Description “Account Sites Container” -Template “STS#0″

Hope This is Hopeful to you..

Friday, May 24, 2013

Add Custom File Attachment Control in the Form of SharePoint

Normally SharePoint provides Document Attachment in the ribbon. But in my case ribbon was hide from the user. So I need to add Attachment Control on the form instead of ribbon. So I achieve it using Client Object Model. Insert the following code in your form to make attachment field available in the Form.
<tr>
<td rowspan="2" width="190px" valign="top" height="50px">
        <H3>
             Upload Evidence
        </H3>
     </td>
     <td valign="bottom" height="15" id="attachmentsOnClient">
         <span dir="ltr">
             <input type="file" name="fileupload0" id="onetidIOFile" size="56" title="Name" /> 
         </span>
     </td>
</tr>
<tr>
      <td colspan="4">
           <input id="attachOKbutton" type="BUTTON" onclick='OkAttach()' value="Upload" style="width: 12.8em; height: 2em"/>
           <span id="idSpace"/>
        </td>
</tr>

Thursday, May 23, 2013

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


Get Field Values in ItemDeleting Event in SharePoint 2010

If you want to get value from a field in ItemDeleting event, you will need to call SPEventProperties.ListItem[“FIELD_NAME”].ToString() method. If you try to get a field value using AfterProperties or BeforeProperties properties, you will get System.NullReferenceException. The reason is these properties are only accessible in ItemUpdating or ItemUpdated events. An example of ItemDeleting event receiver is provider below:
try
{
string fieldValue = "";
fieldValue = properties.ListItem["FIELD_ID"].ToString();
}
catch (Exception ex)
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = ex.ToString();
}

Synchronous and Asynchronous Event Handlers

In SharePoint 2010 it is possible to handle events that occur on list items. These types of events come in two types: Synchronous and Asynchronous Event.

  • Synchronous: happens 'before' the actual event, you have the HttpContext and you can show an error message in the browser and cancel the event

  • Asynchronous: happens 'after' the actual event, there's no HttpContext  and you cannot directly show an error message or cancel the event


By sub-classing Microsoft.SharePoint.SPItemEventReceiver you can override the desired "event" methods.

  • Synchronous: methods ending with '-ing' (ItemAdding, ItemUpdating, ...)

  • Asynchronous: methods ending with '-ed' (ItemAdded, ItemUpdated, ...)


If you implement an override method you might want to place your code between the following lines to avoid raising other events unwantedly (and possibly causing an infinite loop).

this.DisableEventFiring(); 
...
this.EnableEventFiring();


Each override method has a parameter of type Microsoft.SharePoint.SPItemEventProperties that contains the item and event properties available for use. There's a bug in the SPItemEventProperties.AfterProperties dictionary that appears empty for synchronous events but it isn't. You can iterate over the dictionary to read and write to this collection ! This means that you can modify some of the inputted metadata before the actual item is stored in the list.

The thing to remember here is that the dictionary uses the field internal name as key, so field 'Field' could have an internal name such as 'My_x0020_custom_x0020_field'.

Friday, May 17, 2013

How to check member is exist in specific group in SharePoint2010 using javascript

In SharePoint 2010, if you want to check logged in user exists which particular group using javascript as follow:
function IsGroupMember(GroupName)
{
     var isGroupMember = false;
     $().SPServices(
     {
          operation: "GetGroupCollectionFromUser",
          userLoginName: $().SPServices.SPGetCurrentUser(),
          async: false,completefunc: function(xData, Status)
          {
               if($(xData.responseXML).find("Group[Name='" + GroupName + "']").length == 1)                
               {
                    isGroupMember = true;
               }
          }
     });
     return isGroupMember;
}

The above code returns the Group name of the logged in user.

You can use this function as:
if(IsGroupMember("Human Resources"))
{
//your code comes here
}

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();            
}

Friday, May 3, 2013

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

Wednesday, May 1, 2013

Make Windows 8 Boot Directly To Desktop

Would you prefer to have Windows 8 bypass the Start Screen and boot straight to the desktop? If so, you can do so using a technique that takes advantage of a feature that is built right into the operating system - no third-party tools required. All you have to do is create a specially configured task that is scheduled to run at log on.

In this post, I’ll walk you through the steps required to make Windows 8 boot straight to the desktop using a specially configured scheduled task.

As you may recall, in previous versions of Windows, a special shortcut called Show Desktop appeared on the Quick Launch menu. This shortcut was a standard text file that contained five lines of code and was saved with the file extension SCF. The fifth line of that code wasCommand=ToggleDesktop.

To begin you’ll need to launch the Task Scheduler tool. To do so, just press the [Windows] key, type Schedule, select Settings, and click Schedule tasks, as illustrated in Figure A. When you do, the Task Scheduler will appear.

[caption id="attachment_3" align="alignnone" width="594"]Task Scheduler Task Scheduler[/caption]

Configuring Task

Once you have the Task Scheduler up and running, you’ll begin by clicking the Create Task command in the Actions panel, as shown in Figure B.

[caption id="attachment_4" align="aligncenter" width="594"]Create Task Command Create Task Command[/caption]

When the Create Task dialog box appears, you’ll see that the General tab is selected and will first assign the task a name in the Name text box. As you can see, I choose Show Desktop @ Start. Then, towards the bottom of the page, select Windows 8 from the Configure for drop down menu, as shown in Figure C. You can leave the Security options set to Run only when user is logged on.

[caption id="attachment_5" align="aligncenter" width="594"]Creating a Task Creating a Task[/caption]

To continue, select the Triggers tab to access that page, as shown in Figure D. Now, click the New button towards the bottom of the page.

[caption id="attachment_6" align="aligncenter" width="594"]Trigger Command Page Trigger Command Page[/caption]

When you see the New Trigger dialog box, select the At log on item from the Begin the task drop down menu, as shown in Figure E. As soon as you do, the New Trigger page will refresh and display the settings for the At log on option, as shown in Figure F.

[caption id="attachment_7" align="aligncenter" width="594"]When Command Triggered Selection When Command Triggered Selection[/caption]

[caption id="attachment_8" align="aligncenter" width="594"]Command Triggered when User Log On Command Triggered when User Log On[/caption]

By default, the Any user option in the Settings panel and the Enabled check box in the Advanced Settings are selected. Just leave them as they are and click OK to continue. When you return to the Create Task dialog box, select the Actions tab, as shown in Figure G. Then, click the New button towards the bottom of the page.

[caption id="attachment_9" align="aligncenter" width="594"]Command Action Command Action[/caption]

When you see the New Action dialog box, you’ll find that the Action setting is by default set to Start a Program. So, in the Settings panel, you can just type c:\Windows\explorer.exe in the Program/script text box, as shown in Figure H. You can also use the Browse button to locate and select the explorer.exe program. At this point, just click OK to return to the Create Task dialog box.

[caption id="attachment_10" align="aligncenter" width="468"]Specify Action Path Specify Action Path[/caption]

Now, IF you are running Windows 8 on a laptop, select the Conditions tab and in the Power panel, clear the Start the task on if the computer is on AC power check box, as shown in Figure I.

[caption id="attachment_11" align="aligncenter" width="594"]Creating a Task Creating a Task[/caption]

There is nothing that you need to change on the Settings tab so, at this point, you are done and can just click the OK button to complete the scheduled task operation. When you return to the Task Scheduler window, you’ll see the new task that you just created on the Task Scheduler Library, as shown in Figure J. You can now close Task Scheduler.

[caption id="attachment_12" align="aligncenter" width="594"]Schedule a Task Schedule a Task[/caption]

Your task is done now. When Windows 8 restarts, you’ll immediately see the Desktop with a File Explorer window targeted on Libraries, as shown in Figure M. You will not see the Start Screen at all.

(Keep in mind that when you see the File Explorer window targeted on Libraries, the Documents Music, Pictures, and Video icons may shuffle around a bit. The reason for this is because when the File Explorer window appears on the screen, the operating system is still doing a bit of housework in the background.)

[caption id="attachment_13" align="aligncenter" width="594"]Windows 8 Desktop Windows 8 Desktop[/caption]