Sunday, 7 June 2015

Programmatically Updating the Infopath forms and UDCX files after migration - SharePoint Powershell

Hi All,
 Today we will see about Infopath. We had a SharePoint migration in our company from 2010 to 2013. This Powershell cmdlet helped very much in reducing the manual time for updating the data connections in the Infopath forms.

 Once migration is done, the Infopath will be still pointing to the Old URLs in the data Connections.
Example: If the Old URL is something like "http://contoso2010.Company.com" and the New URL is like "http://contoso2013.Company.com", and after migration also the Data Connections will be pointing towards "http://contoso2010.Company.com". This includes the UDCX files also.

If there are only few forms, we can change it easily by following the below method.

For Updating in the forms : Just open the form in the Infopath designer, in the "DATA" tab click on "Data Connections". Check whether it is poinint towards our new URL. If not update the same and re-publish.

For Updating the UDCX files : Open the Data Connections Library and download the files to the Loca. Open the files in the notepad and change the "Web URL" and "List ID" parameters to the latest.

The above method will be helpful only if there are few forms. If there are more forms to be manually updated you can always go for the below PowerShell method.


The Update-SPInfoPathUserFileUrl cmd-let will upgrade form template and data connection files as per the parameter we give in the cmdlet. The update will access ALL files (except ASPX files) in any Data Connection library anywhere in the site and Update.

CMD-LET is

Get-SPWebApplication http://contoso2013 | Update-SPInfoPathUserFileUrl-find "http://contoso2010" -replace "http://contoso2013"

This example updates data connections in InfoPath form templates and universal data connection files, for all content under the Web application http://contoso2013. Data connections that reference http://contoso2010 are updated to reference http://contoso2013.

This also works for Admin approved Infopath forms :Update-SPInfoPathAdminFileURL -find "http://contoso2010" -replace "http://contoso2013".

The same method could be followed when moving the forms from Test to Production.

Thanks for Reading.. See you in the next post.. Happy Sharepointing..................



Sunday, 15 March 2015

Odata querying 100 items only issue - SharePoint

Hi Coders,
 This post will be useful for the beginners, who has already started using Odata in SharePoint 2013. You might have faced this issue or you havent figured it out yet.

For Odata queries please refer this.

So based on the above link, for retrieving items from the list , we have to use the following syntax.
http://server/site/_api/web/lists('guid')/items?$select=Title
This provides you the "Title" column value of  the items in the list.

So, the tweak in this query is, by default it returns only 100 items..
This important point has been missed in most of the documentation..


FIX : 
So to fix this we have to use the "top" clause.
http://server/site/_api/web/lists('guid')/items?$select=Title$top=10000

We have to give a maximum value based on our application nature.

Hope this helps..

Have a good day. Meet you on the next post.
Happy Sharepointing......

Sunday, 30 November 2014

User Information List in SharePoint

The User Information List stores information about a user by having some metadata set up for the user.
When a user is granted access to a site, a new item will be created in the User Information List storing some information about the user.

When a user add/create or edit an item, SharePoint will display something like "Last modified at 1/1/2014 by myname myname" . Displayname is gathered from the User Information List.

The User Information List can be accessed (Only if you’re admin) via the browser by navigating to /_catalogs/users/simple.aspx from your site.

User information list is filled with user info when:

1. you grant permissions directly to this user (not via group)
2. user visits site collection first time (users are stored on site collection level, not on site. The fact that /_catalog/users may show different users on different site on the same site collection just says that there is some additional filtering logic)
3. you call SPWeb.EnsureUser() programmatically.

Note: This list is only visible to and accessible by administrators.

Thursday, 23 October 2014

Content Query WebPart returning no data - Sharepoint 2013

Hi All,

Its been a long time since i had posted. Last week i got a weird issue, that made me do this post.

Content query webpart helps in retreiving the data throughout your Site Collection. In Sharepoint 2013 when I used this CQWP to get data, I had a condition where no data were retrieved. In this condition, the HTML of that particular page got distorted and the webpart zones got shifted.
So everything went on to a mess. It took some time for me to get the fix for this issue.

Please find the solution to fix this issue.

Open the ContentQueryMain.xsl in SharePoint Designer. Find the XSL template OuterTemplate.Empty. As you can see it poorly handles the "no items" situation.

Replace the template with this:

<xsl:template name="OuterTemplate.Empty">
  <xsl:param name="EditMode" />
  <xsl:choose>
    <xsl:when test="$EditMode = 'True' and string-length($cbq_errortext) = 0">
      <div class="wp-content description">
        <xsl:value-of disable-output-escaping="yes" select="$cbq_viewemptytext" />
      </div>
    </xsl:when>
    <xsl:otherwise>
      <div style="display:none">No content found</div>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Have a good day :)

Friday, 4 July 2014

Jquery selectors - Wildcards for Finding Sharepoint fields with Internal Names in newform,editform and Displayform.

Hi All,
 Today we will see something related to jQuery. This was helpful when i tried to get the internal names of the columns in the newform, editforms.

Getting the controls in the forms using the label names would be inconsistent, as the labels could be changed frequently causing our code to break. So we have to query the fields using "id" of that element.

For example, if there is a control named "Project Name", its id could be "ProjectName_12h1278hk9kkhasfkcyh9"..

That is, "Internal Name of the column("ProjectName) + some junk"

These wild card selectors were very useful in finding the controls. This would be of a great help when u come across these sort of situations.


If you want to select elements with an id which ends with a given string :
$("[id$='myValue']")


If you want to select elements with an id which starts with a given string :
$("[id^='txtTitle']")


If you want to select elements which id contains a given string  :
$("[id*='txtTitle']")


If you want to select elements which id is not a given string  :
$("[id!='myValue']")
(it also matches the elements that don't have the specified attribute)


If you want to select elements which id contains a given word, delimited by spaces :
$("[id~='myValue']")


If you want to select elements which id is equal to a given string or starting with that string followed by a hyphen:
$("[id|='myValue']")


Have a good day....

Tuesday, 3 June 2014

Sorting the Lookup field values based on any columns on Lookup list using SPServices SPFilterDropdown

Hi Everyone,
 Today we will be seeing a common requirement which will used very frequently, and there is OOTB way to do this.

The requirement is "sorting the Lookup field values". Usually it gets sorted automatically "alphabetically".

Sometimes, we need to have them as in same order as they have stored in the list. For this we are going to sort the values of the lookup based on the ID on the lookup list.
Note : The lookup values can be sorted based on any columns. That depends on the requirement. For understanding i have used ID for that.

For this we are using SPServices, For using SPServices and to have a basic knowledge about SPservices, please refer here.

 $().SPServices.SPFilterDropdown({ //This is the function that does the sorting.
        relationshipList: "LookUp list", //This is the lookup list.
        relationshipListColumn: "Title", //This is the original column name from the lookup list as SharePoint knows it.
        relationshipListSortColumn: "ID", //This is the column in the lookup list to sort by.
        columnName: "LookUpcommitees", //This is the lookup field name .
        debug: true// have to be true on development times
    });


Have a good day:)

Saturday, 19 April 2014

Site Pages and Site Assets missing in your Newly Created SharePoint Site?

Sometimes when you create a site in SharePoint 2010, the Site Pages and Site Assets libraries are not created, yet other times, they are?

The answer lies in a feature called Wiki Page Home Page, which is enabled by default for Team Sites in SharePoint. However, other types of site templates may not activate that feature by default, and if that’s the case, those libraries won’t be there.

If you need them, you have a few options:
  • Activate the “Wiki Page Home Page” feature. The feature will create those libraries and will also create a wiki page and set it as the home (welcome) page for your site.
  • If you only need the libraries and don’t want your home page changed, you can have SharePoint Designer 2010 create the libraries for you:
    • Open SharePoint Designer.
    •  In the “Site Objects” pane on the left, click “Site Pages.” SP Designer will load the contents of the Site Pages library and tell you it’s empty. However, it also creates the Site Pages library for you in the process.
    • Do the same thing for “Site Assets” (also in the Site Objects pane). 
  • If you have code that depends on the existence of these libraries (such as a feature receiver), you can use two methods on the SPListCollection class to ensure the libraries are there:
    • EnsureSitePagesLibrary()
    • EnsureSiteAssetsLibrary()

Happy SharePointing!!!:)