Showing posts with label Sharepoint. Show all posts
Showing posts with label Sharepoint. Show all posts

Wednesday, October 29, 2014

Infopath Error: The Query cannot run, Infopath cannot run the specified query. Access denied.

 Creating a InfoPath form for a document library in one of my project, publish the infopath form I got an error saying that “InfoPath cannot run the specified query. Access is denied”.
I have verified few blog posts and verified following options,
  • Permissions to document library and site – Yes iam having Full Control over site and Document library
  • Domain – Yes iam in VPN with the same network

But User cannot submit a form to SharePoint if the security level is ‘Restricted’ . We need to have Domain Trust should be Full Control or more.
To grant Full control we have to follow the steps below,
In the InfoPath File Click on “Form Options” as shown the image below,



In Form Option popup, Security and Trust, Select “Full Trust” on security level as shown the image below.



Click on Ok to save the settings. Now we can publish the InfoPath form with out errors. 

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. 


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.