Friday, 28 September 2012

Deploy SharePoint 2010 solution(.wsp) package using Powershell

Deploy SharePoint 2010 solution(.wsp) package using Powershell

In this article we will discuss how to deploy the SharePoint 2010 solution package (.wsp) using PowerShell

Step1:  Start Power Shell command prompt
Start->All Programs->MicrosoftSharepoint2010Products->open Sharepoint2010Managementshell

Type the command

Step2:  Add Solution Package
Add-SPSolution “C:\SharePoint2010Solution.wsp”

Step3:  Install Solution Package
Install-SPSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment

If you are using Sandbox Solution,

Step4: Install Solution Package
Install-SPUserSolution –Identity SharePoint2010Solution.wsp     –WebApplication http://myserver  –GACDeployment

For Updating the Sharepoint 2010 Solution type the following commands

Step5: Update Solution Package
Update-SPSolution –Identity SharePoint2010Solution.wsp –LiteralPath “C:\SharePoint2010Solution.wsp” –GacDeployment

For retract and remove a solution, type the following commands:

Step 6: Uninstall Solution Package
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication    http://myserver

Step7: Remove Solution Package
Remove-SPSolution–Identity MySharePointSolution.wsp

WSP Deployment Using Power Shell


Command for WSP Deployment Using Power Shell in SharePoint 2010 Server

1.Develop Custom Webpart
Open PowerShell and Run as Administrator
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
Adding
————
write-host “Adding Snapin”
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Added”
Add-SPSolution “D:\MySPSolution.wsp“
Install-SPSolution –Identity MySPSolution.wsp –WebApplication http://EXCH2010:9006 –GACDeployment
Update wsp
————-
Update-SPSolution –Identity MySPSolution.wsp –LiteralPath “D:\MySPSolution.wsp” –GacDeployment
unInstall wsp
————-
Uninstall-SPSolution –Identity MySPSolution.wsp –WebApplication http://EXCH2010
Remove-SPSolution–Identity MySPSolution.wsp
Or below
Uninstall-SPSolution -identity MySPSolution.wsp -Confirm:$false
Remove-SPSolution -identity MySPSolution.wsp -Confirm:$false
===========================================================================================================
Specific to One site
=========================================================================================================
————–
write-host “Adding Snapin”
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Added”
Adding
—–
Add-SPSolution “C:\CustomWebPartTest.wsp”
Install-SPSolution –Identity CustomWebPartTest.wsp –WebApplication http://EXCH2010:9006 –GACDeployment
Update wsp
————-
Update-SPSolution –Identity MySPSolution.wsp –LiteralPath “D:\MySPSolution.wsp” –GacDeployment
Uninstall
————–
Uninstall-SPSolution –Identity CustomWebPartTest.wsp –WebApplication http://EXCH2010:9006 -Confirm:$false
Remove-SPSolution -identity CustomWebPartTest.wsp -Confirm:$false
write-host “Removing Snapin”
Remove-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Removed

Wednesday, 8 August 2012

The test form is only available for requests from the local machine.

Sometimes when you try to open your web service form a local network machine, that time you may get the below error:

"The test form is only available for requests from the local machine.

SOAP 1.1

The following is a sample SOAP 1.1 request and response.......

SOAP 1.2

The following is a sample SOAP 1.2 request and response.........
"


This is the configuration settings problem, Open the web.config file of ASMX Service in IIS add the following config, then you can browse from your local network.

<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>

Now you can able to see the "invoke" button.

Happy Coding :)

Tuesday, 7 August 2012

Working with SQL Server Reporting Services

To achieve this task you must have an instance of SQL Server Reporting Services and SharePoint 2010.
Step 1: Configuring SQL Reporting Services – Web Service URL
Go to Reporting Services Configuration Manager and choose Web Service URL and populate the following needed information. The fields are named properly so I guess there is no need for further explanation. What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.

Step 2: Configuring SQL Reporting Services – Create a Report Database
Same here, fields need no further explanation except for one which is Native Mode and SharePoint Integrated mode which I will explain below.
Choose create a database or if you already have one choose an existing one. For this example, we will create a new one:

Connect to the database where you want your Report Data to be stored:

Give it a Name and a Report Server Mode.
With SharePoint Integrated Mode the report RDLs are stored on SharePoint and not in the Report Database. For this instance, we will use the SharePoint Integrated Mode:

Specify the credentials that the report server will use to connect to the database.

Review your configuration.

Then wait while it's configured.

Step 3: Configuring SQL Reporting Services – Create a Report Manager URL
What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.

That’s it. At this point, your report server is configured for SharePoint Integration 2010.
Step 4: SharePoint Integration Configuration – Reporting Services Integration
Simply go to SharePoint 2010 Central Administration, then General Application Settings, then choose Reporting Services Integration.

Now populate the fields using the Web Service URL you had configured a while ago on Step 2 of this guide.

Once done, you will see the Activation State message.

Step 5: SharePoint Integration Configuration – Add a Report Server to the Integration
Now add the report server by putting the Server Name and the Server instance.

At this point it's all done, all you have to do now is try it out.
Step 6: Verify by Checking the Server and Uploading a Report
To verify if it's now integrated, go to Site Settings on your SharePoint Site, then Site Collection Features.


Check if the Report Server Integration Feature is Active, if not just click activate:

Now try to use the SQL Server Reporting Services Webpart:


Or you can also upload a report from a library.

It's over..... Happy Coding :)

Thursday, 7 June 2012

Improving Your SharePoint User Experience with jQuery Client Side Form Validation

SharePoint forms for the lists NewForm.aspx and EditForm.aspx can validate a variety of things. For example, you can make a field be a required field and the forms will force the user to input something. Additionally, you also can specify that a SharePoint column be of type “something other than text” (types such “Numbers” and “Dates”) and SharePoint will enforce validations on those fields as well.

Problem:

However, you can not specify a SharePoint column to be of type “email addresses” or “phone number” .They are just treated as text and the values’validity are not enforced.

Here is an example:

Note: You cannot validate a field’s value on the client-side, which means that when click “OK“, you need to refresh the entire page before you can determine there are input errors.

Solution:

This solution will enable you validate forms on client side and in real time.


1. First we need jQuery JavaScript library and the jQuery Validation Plugin.

2.Upload the validation plug-in into a “jquery” library in your SharePoint site.
JQuery Validation Plugin is written and maintained by Jorn Zaefferer, a member of the jQuery team, lead developer on the jQuery UI team and maintainer of QUnit. It was started back in the early days of jQuery in 2006, and updated and improved since then.

3. Next, open the SharePoint Site and edit the list‘s NewForm.aspx or EditForm.aspx in SharePoint Designer.

4. In this example, we are editing the Contacts List EditForm.aspx.

a. Click “All Files_Lists,” and find the contact list.

b. Right-click the NewForm.aspx, and choose “Edit File In Advanced Mode.”


c. Add links to the jQuery script and the plugin with following code:


5. So once you have all the scripts you need on the page, we just need to attach the behavior to the form field. To do this we can add some JavaScript to the page in a Content Editor web part.

6. Return to SharePoint. SharePoint will launch the list forms in a dialog by default. It is not convenient to edit pages.

7. Close Dialog Mode by modifying List Setting-> Advanced Setting-> Dialogs.



8. Now, open our list, and click “Add new item.”

9. Open NewForm.aspx.


10. Select the Site Actions -> Edit Page, enter edit mode.

11. Insert an HTML Form Web Part.

12. Open WebPart Properties -> Source Editor.

13. Delete the default HTML content.

       $(document).ready(function () {
           var validator = $("form").validate({ errorClass: "ms-formvalidation" });
           $("input[title='E-mail Address']").rules("add", { email: true });
           $("input[title='Last Name']").rules("add", { required: true });
           $("input[title='Business Phone']").rules("add", { phoneUS: true });
           $("input[title='Home Phone']").rules("add", { phoneUS: true });
           $("input[title='Mobile Phone']").rules("add", { phoneUS: true });
           $("input[value='Save']").each(function () {
               var js = $(this).attr("onclick");
               $(this).attr("onclick", "");//remove sharepoint click handler...
               $(this).click(function (event) {
                   if (!validator.form()) {
                       return false;
                   } else {
                       //call sharepoint click handler..
                       eval(" ( function () {" + js + " })();");
                   }
               })
           })
       });

Friday, 1 June 2012

Webservice to get data form sharepoint list


Below is the Sample Code to get the data form SharePoint List using Web Services

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Xml;


namespace SharepointWebService
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
       
        public XmlNode NewExtentians()
        {

            WS_Lists.Lists lists = new WS_Lists.Lists();
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential(username,password);
            string rowLimit = "5";
            lists.Credentials = cred;
            XmlNode n = lists.GetListItems("Listname", null, null, null, null, null, null);
            return n;
        }
    }
}

--
Done :)

How to open Modal Popup (NewForm.aspx) on image click

If you want to open the NewForm.aspx page of  list/library on click of an image, then you have to follow the below steps:

Step-1: Add a content editor in the page.
Step-2: In HTML source add the below code:

<a href="javascript:var options = {url:'/sitename/Lists/listname/NewForm.aspx?IsDlg=1&ContentTypeId=0x001989BCF16D8914CAF8862B0C6C89E091E', title: 'Popup Title'}; void(SP.UI.ModalDialog.showModalDialog(options))"><img _moz_resizing="true" alt="AddNew.BMP" src="Image Path" style="margin: 5px;"/></a>

Step-3: Save and Close the HTML Source
Step-4: Click on Stop Editing

Its Done

Happy Coding :)