Tuesday, September 30, 2014

SharePoint Restore-SPSite error - Response message does not match the content type of the binding

While working with SharePoint site  restoring with PowerShell commands I got an error saying that, 

Restore-SPSite : The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly

After googling some time I got the cause and fix for the solution. In my case in my current secured store service web application web.config file we have some duplicate nodes for forms based configuration.

To fix that we need to follow the steps below,
  • Open SharePoint server form and open IIS manager.
  • Open SharePoint Security Token Service Application and Explore the web application details for web.config file.
  • In the web.config file verify the duplicate nodes and check all the nodes are allocated properly in the web.config file. In my current scenario we got extra node in forms based authentication configuaration. I have removed the duplicate node and restored the site.


Now I am able to restore the site. Hope this will helps.



Saturday, September 27, 2014

SharePoint – Back to basics – Designer quick tips – All Items in navigation, Updating List URL

I got a simple requirement for one of my project to update the list URL. Basically this is a simple requirement by using Object model/PowerShell commands. But we don’t have option to use PowerShell commands or coding. Even without them we can update that easily from SharePoint designer. This is simple option I haven’t seen/worked on earlier.

We can update the list URL by navigating to designer All Items -> Lists folder. But unfortunately I can’t find All item option in designer. By default we can’t see that option. To enable that option we have to enable the option in Central Administration as the steps below.

Navigate to SharePoint central administration General Application settings. Click on “Configure SharePoint Designer Settings”



To enable SharePoint designer to a site we have to check “Enable SharePoint Designer ” to see All items option we have to check “Enable Managing of the Web Site URL Structure ” option as shown below.



To change the List URL click on “All Items” in designer. We can see the list of all the contents. Click on Lists folder.




Select the list to change the URL, right click and select Rename option.


Rename the list as per the requirement. By updating the list name URL of the list will be changed. Here before changing the list URL looks like http://SiteURL/Lists/TestCustom/AllItems.aspx . I have updated the name as Testlist. By updating the name URL updated as http://SiteURL /Lists/Testlist/AllItems.aspx .



Sunday, September 21, 2014

SharePoint InfoPath form Allow anonymous users to enter data

SharePoint InfoPath forms is one of the way to enter data into SharePoint. To allow anonymous users to enter the data in the forms we have to follow the steps below,
  • Configure Anonymous access to SharePoint site
  • Create a list that to submit data anonymously, Change anonymous permissions to the list and update list form to InfoPath form

To configure Anonymous access to Site, navigate to SharePoint central Administration, Navigate to Application management -> Manage Web Applications.

Select the web application, click on “Authentication Providers” in the ribbon. Check “Enable anonymous access” checkbox to Enable Anonymous Access to web application.



To Enable Anonymous access to SharePoint site, Navigate to SharePoint site where we need to allow users enable anonymous access. Open Site Settings, Select Site Permissions. In Ribbon, Permissions Tools section, click on Anonymous access button.



Select Entire Web site option in Anonymous access popup.



Create a List in the site. In List permissions, Break permissions from Parent and Enable Anonymous access to Add items to list.














Customize the InfoPath form by  using Customize List option in the ribbon. 


SharePoint 2007 error while opening the site in designer - this website has been configured to disallow editing with SharePoint designer

One my client having SharePoint 2007 environment. We got some requirement to check the existing functionality in one of the site. To verify the existing web parts I have tried to open the page in SharePoint designer. 

While opening the site in SharePoint designer 2007, I got the error saying as “This website has been configured to disallow editing with SharePoint designer.”I am having Site Collection Admin privileges over the site and having Farm Admin credentials on the server.


In my current site designer settings are disabled. In SharePoint 2013/2010 environments we can enable designer settings through SharePoint central Administration. But in SharePoint 2007 we have to enable through onet.xml file located in file system 12 hive.

To enable designer settings, Navigate to 12 hive templates folder located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extentsions\12\Template\SiteTemplates \XML , (Here Site Templates is generic folder, Depending on site template we have to choose the folder)
Select  Onet.xml, Open it with any text editor. Check for “<Project Title” tag and Remove “DisableWebDesignFeatures=wdfopensite” text. Save Onet.xml file and Reset IIS by running IISRESET command.

By removing the text from Onet.xml file we can enable editing through designer. But to update this change in Onet.xml file we need to have farm admin permissions on the farm.

Hope this helps.

Tuesday, September 16, 2014

SharePoint content type error “The content type is in use”

One of my project from recent times I was worked on content hub to manage the content types in SharePoint. While changing the content type name, I got an error saying that “The content type is in use” as shown the image below.



I have checked all the content types in current site, I haven’t seen any content type with the current name. By checking few blogs like mavention and sympmarc I got the reasons for this error.

There many reasons for this issue as listed below,

Content type still exists in Site: Even we can’t see the content type in SharePoint content type gallery, it may exists in Recycle Bin (Site Recycle Bin or Site collection Recycle Bin). We have to remove the content type from Recycle Bin too. To remove the content type from Site Collection Recycle Bin, we need to have Site Collection privileges on Site Collection.

Other users might have associated anywhere? There is another chance that other users might have associated with the content type that we can’t see. We can see this behavior in SharePoint document libraries. We can check this by navigating to SharePoint Library settings and click on Manage Check out files. We can see the list of items belongs to other users. If it ok, take the owner ship of the items and check-in them.

Minor Versions:  We have one more possibility that there are some items may checked-in with minor versions in the List/Library. We have to check the appropriate items and need to publish the items with major versions.
This may helps.


Wednesday, September 10, 2014

Check SharePoint service status using SharePoint object model

By using SharePoint object model we can retrieve the User Profile Service information like User Profiles and user group details from UserProfileManager class. Some times we can see “UserProfileApplicationNotAvailable” error. We can check service availability details using following code block.

public bool IsCurrentServiceisInStart(string serviceName)
{
    bool currentServiceisInStart = false;

    SPService currentService = SPFarm.Local.Services.FirstOrDefault(s => s.TypeName.Equals(serviceName));

    if (currentService!= null )
    {
        SPServiceInstance serviceInstance  = service.Instances.FirstOrDefault(i => i.Status == SPObjectStatus.Online);
        If(serviceInstance !=null)
                currentServiceisInStart=true;
    }

    return currentServiceisInStart;

}

We can check the current service from SharePoint local services by mentioning the service application details as “SPFarm.Local.Services.FirstOrDefault” command in Linq.

We can use this code block while calling SharePoint service application. Hope this will help.

Sunday, September 7, 2014

SharePoint – Back to basics – Impersonate user programmatically

In SharePoint custom development activities, we have to impersonate the user to view SharePoint contents. To impersonate user in SharePoint we need to have the account that having privileges (generally in Run with elevated privileges “System Account” will be used) or user tokens.
To handle with System Account, we can use following code block,

SPSite parentSite = new SPSite(siteURL);

SPUserToken systemToken = parentSite.SystemAccount.UserToken;

using (SPSite site = new SPSite(siteURL, systemToken))
{
    using (SPWeb web = site.OpenWeb())
    {
        // Code to be run
    }
}

We can impersonate the by using following code by getting the user token of the user to switch as shown the code below,

SPUserToken userToken = web.AllUsers[user].UserToken;

// Create an SPSite object in the context of the user
SPSite site = new SPSite(siteURL, userToken)
SPWeb web = site.OpenWeb();

//Add code here.

To run this code, we need to run the code System account


SharePoint custom workflow send email task error: The e-mail message cannot be sent. Make sure the email has a valid recipient

While working with SharePoint custom workflow with Send email task, i am seeing “The e-mail message cannot be sent. Make sure the email has a valid recipient” error in workflow history list every time workflow fired. I was in a confusion that why I am seeing that every time.

Very first time designing workflow I have left all properties for “Send Mail” task empty as I am sending emails through code without interacting any property in Send mail task. I have updated all the properties by creating new Field Properties in the code. But still seeing the same error in workflow history list.

By checking few posts, the error may cause because of two reasons,
  • ·         There is no e-mail in Active directory for system Account.
  • ·         Getting null values for existing properties as not assigning the values.

Here in my case iam getting null values from field properties. So I have updated a dummy email in To field as I am not using the the property anywhere in the code.

Hope this will helps.

Thursday, September 4, 2014

InfoPath error – “Your user name or group membership cannot be verified because the form's security settings do not permit it.”

Working with existing InfoPath forms, while opening the form it is showing error as “Your user name or group membership cannot be verified because the form's security settings do not permit it.” As shown the below.



 We can get this error due to form security error. To fix that we need to add the site to local sites by using the steps below.

Navigate to IE and open Internet Option from IE settings.


In the Security Tab, Select “Local Intranet” option and click on Sites button.


You can see “local Intranet” popup, click on “Advanced” button.


Add the Site to local intranet sites by clicking on Add button. Click on Close button.


Click on Ok button to Save “local Intranet” popup and Ok button to close internet options.

By opening the form we can see the form without any errors. Hope this helps.

Wednesday, September 3, 2014

Customize SharePoint survey through UI

In SharePoint survey we don’t have option to edit the survey views and details. In my project, we need to add a column with to response to survey which works as a normal list item. This column need to save the response of the survey. I have tried to do this through UI and I am unable to do that as regular list options. I have checked it in google, few answers says that it is nearly impossible to do that through UI and we have to go for custom coding.

By checking few more links I got a clue to do that. It says that a designer workflow will collect the feedback from the user who responds the survey and workflow fills the response details to survey. That’s great. I got the fix for that.

To create new view in survey list,
  • ·         Open the new view page in SharePoint site, copy the URL to a notepad. URL shows like “/_layouts/15/ViewNew.aspx?List=%7B0C3E3AB1%2D555D%2D4FE0%2DB9B3%2DB58BE4D36D22%7D”
  • ·         Open Survey settings page, Replace the Survey list id with previous URL.


To create a new column in SharePoint survey list, Open Site with concating following URL “/_layouts/fldNew.aspx?ListID=” Add survey list ID.


These are quick hacks for SharePoint survey list. Hope this helps.