Friday, August 7, 2015

Auto-numbering InfoPath forms for large SharePoint form library

Recently i observed one issue- users were not able to create tickets on form libraries which having many items or say libraries crossed threshold limit.

Some form libraries used max(@ID) + 1  logic to get last item ID for ticket creation and some used XML Connection using SharePoint View. Both the options doesn't work for form libraries which having many items.

Best solution to overcome this issue is, use REST connection to get last item ID. Use below REST URL format




Tuesday, June 2, 2015

Get all sites in a SharePoint Site Collection using the PowerShell and CSOM

$host.Runspace.ThreadOptions = "ReuseThread"

#Function definition
function Get-AllSites($siteUrl, $userName, $password, $domain)
        #Save result in temp variable
        $results = @()

        #Create client context
        $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) 
        $credentials = New-Object System.Net.NetworkCredential($userName,$password,$domain)  
        $ctx.Credentials = $credentials 

        #Get site
        $rootSite = $ctx.Web
        #Loading root site     
        foreach($site in $rootSite.Webs){
            #Load sites under each subsite

            Write-Host $site.Url -ForegroundColor Green
            #Create object for CSV row           
            $details = new-object PSObject
            $details | add-member -membertype NoteProperty -name "Site URL" -Value $site.Url
            $results += $details

            #Go for subsites if it has child sites
            if($site.Webs.Count -gt 0) {

                $results += Get-AllSites $site.Url $userName $password $domain
    catch [System.Exception]
        write-host -f red $_.Exception.ToString()   
    return $results

$siteUrl = "http://contoso/sites/hr"
$userName = "username"
$password ="password"

#Add Client Object Model Assemblies        
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Call fuction
$path = Get-Location
Get-AllSites $siteUrl $userName $password $domain | export-csv -Path $path\List.csv -NoTypeInformation

Write-Host "Report exported to CSV, please check file on location: $path"


Tuesday, April 14, 2015

Relink InfoPath form using Nintex Workflow

In one of my recent project i wanted to copy InfoPath Form from one library to other- second library InfoPath Form template was exactly similar but included few more fields.

In second library i created workflow and used Update XML action, configure it as below

XPath Query


In second text box use PI information as below format.

name="urn:schemas-microsoft-com:office:infopath:LeaveForm:-myXSD-2015-02-27T14-45-21" solutionVersion="" productVersion="" PIVersion="" href="https://contoso/LeaveRequestArchive/Forms/template.xsn"

Friday, December 19, 2014

SharePoint Apps Privacy Policy

Privacy Policies

I am committed to protecting your privacy. The Privacy Statement applies to the SharePoint app(s) provided by using my name-Sandip Patil and governs data collection and usage. By using my SharePoint app(s), you consent to the data practices described in this statement.

Collection of your Personal Information
My app(s) does not collect any personally identifiable information.

Sharing of Information
My app(s) does not share or transfer any personal information with third parties.

Lost and Found App on SharePoint App Store

Lost & Found App is a best place for recovery of lost and found items within a company. Just place it on home page of company intranet portal and start using it.

Key features
  • Very simple and user friendly interface
  • Simple form for items reporting
  • Autocomplete suggestions for item search
  • App part available so it's very easy to place this app on site pages
  • No administration needed

App home page


Search Item: Type minimum 4 characters to get search results

Add Item: Title, Description and Category are mandatory fields

Display Item: Delete button is visible only for your own item

App Part: Add this App as app part on the site pages

I welcome your comments and suggestions. Thanks and enjoy the app..!

Thursday, November 20, 2014

Unable to navigate to SharePoint Hosted App and getting Invalid URL message

Our team had been working on one SharePoint Hosted App for couple of days, one day some team members were getting Invalid URL error after installing App to Developer site. Error message is

Invalid URL: ~appWebUrl/Pages/Default.aspx?SPHostUrl=https%3A%2F%2Fsportsoffice%2Esharepoint%2Ecom&SPLanguage=en%2DUS&SPClientTag=18&SPProductNumber=16%2E0%2E2930%2E1217&SPListItemId=1356&SPListId={A80C0C18-8AA6-4D27-9A2A-9E7556539D94}

We all sat together and tried to recollect what we did in last few days, we were using TFS as source control and everybody were check in their code at the EOD, so we checked version history and found that Package folder and package manifest lines in .csproj where missing in project.

Due to this Visual Studio couldn't build right App package, it missed App WSP in published package.

Just restoring Package folder and .csproj file fixed our issue.

Wednesday, November 5, 2014

Get web part assembly name and type name from SharePoint web part gallery

Today i was trying create to custom webpart preview page as test canvas for site admins. For this i wanted to add webpart on fly.  We need few properties like web part type name and web part assembly name for this.

string webPartTitle = " Content Editor Web Part";
string webPartTypeName = string.Empty;
string webPartAssemblyName = string.Empty;

SPList wpGallery = SPContext.Current.Site.GetCatalog(SPListTemplateType.WebPartCatalog);

SPQuery wpQuery = new SPQuery();

wpQuery.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + webPartTitle + "</Value></Eq></Where>";
SPListItemCollection items = wpGallery.GetItems(wpQuery);

if (items != null && items.Count > 0)
       webPartTypeName = items[0]["WebPartTypeName"].ToString();
       webPartAssemblyName = items[0]["WebPartAssembly"].ToString();

Some other useful properties are below

- WebPartDescription
- WebPartPartImageLarge
- LinkWebPart
- WebPartIcon
- Group
- QuickAddGroups