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

Wednesday, June 4, 2014

SPGrid Error in SharePoint 2010: System.ArgumentNullException: Value cannot be null. Parameter name: container

While working with SharePoint 2010 Grid view grouping depending on dropdown value, got an error saying that “Value cannot be null. Parameter name: Container” as shown the image below.
















Iam unable to find the issue while debugging the code. I have spent much time on this issue finally got the reason. By making “EnableViewState” to false error got fixed as show the code below.

grdPropertyValues.EnableViewState = false;
grdPropertyValues.AllowSorting = true;
grdPropertyValues.AllowGrouping = true;
grdPropertyValues.AllowGroupCollapse = true;



Here grdPropertyValues is SPGridview object. Hope this helps.

Saturday, May 17, 2014

SharePoint 2010 installation Error – Could not create Configuration database

While installing SharePoint, I got an error saying that “Could not create Configuration database - Failed to call GetTypes on assembly Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c The system cannot find the file specified. Could not load file or assembly 'Microsoft.Office.InfoPath, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies.

I have rechecked pre-requisites and re-installed all the pre-requisites. But still Iam facing the same issue. By checking the issue in deep I have found that issue is related to InfoPath. In my machine Iam having InfoPath 2013. It’s blocking SharePoint Configuration wizard to create database.

To fix this issue we have to uninstall InfoPath from current machine. After uninstalling the InfoPath Configuration wizard ran successfully.

Hope this helps.

Friday, May 16, 2014

SharePoint – Back to Basics – SharePoint URL field link open in new window using JavaScript

One my project I got a requirement that in SharePoint URL field we have to open the link in new window. But URL field, we don't have option to open the link in new window through UI. For that I have added custom JavaScript in Content editor web part/Script web part.

Before updating JavaScript we have to add #Opennewtab at the end of the URL in URL field as Show the image below.



Add following JavaScript to the List items page through Content Editor web part/ Script editor web part.

<script language="JavaScript">
_spBodyOnLoadFunctionNames.push("UpdateLinks");
function UpdateLinks() {
var anchorsTags = document.getElementsByTagName("a");
for (var x=0; x< anchorsTags.length; x++) {
if (anchors[x].outerHTML.indexOf('#Opennewtab)>0)
{
                oldText = anchors[x].outerHTML;
                newText = oldText.replace(/#Opennewtab/,'" target="_blank');
                anchors[x].outerHTML = newText;
}
}
}
</script>

After adding this script save and close the web part. All the links added with #OpeninNewtab will be open in new window.

Saturday, April 19, 2014

Send meeting request in SharePoint custom workflow

Working with SharePoint workflow I got a requirement to send meeting request by using the code. I have dig into deep to check if there is any option to send meeting requests by using SharePoint workflow but I couldn’t find anything. So we have only option to send meeting request through C# code.
My friend Ravi helped me on the code finally by using the code below we are able to send the meeting requests.

private void SendMeetingRequestMail(VacationRequestMail reqMail, string smtpTO, string smtpServer, string smtpFrom)
        {
            using (MailMessage mailMessage = new MailMessage(smtpFrom, smtpTO))
            {
                mailMessage.Subject = “Subject”;
                mailMessage.Body = “Body”;


                DateTime startDate = “Start Date and Time
                DateTime endDate = “End Date and Time

                StringBuilder str = new StringBuilder();
                str.AppendLine("BEGIN:VCALENDAR");
                str.AppendLine("PRODID:-//Vacation Request Portal");
                str.AppendLine("VERSION:2.0");
                str.AppendLine("METHOD:REQUEST");
                str.AppendLine("BEGIN:VEVENT");
                str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startDate));
                str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endDate));
                str.AppendLine("LOCATION: Vacation Request Portal, India");
                str.AppendLine(string.Format("X-MICROSOFT-CDO-ALLDAYEVENT:TRUE"));
                str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
                str.AppendLine(string.Format("DESCRIPTION:{0}", mailMessage.Body));
                str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", mailMessage.Body));
                str.AppendLine(string.Format("SUMMARY:{0}", mailMessage.Subject));
                str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", mailMessage.From.Address));
                str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:FREE");
                str.AppendLine("BEGIN:VALARM");
                str.AppendLine("TRIGGER:-PT18H");
                str.AppendLine("ACTION:DISPLAY");
                str.AppendLine("DESCRIPTION:Reminder");
                str.AppendLine("END:VALARM");
                str.AppendLine("END:VEVENT");
                str.AppendLine("END:VCALENDAR");
                System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
                ct.Parameters.Add("method", "REQUEST");
                AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
                mailMessage.AlternateViews.Add(avCal);

                using (SmtpClient smtpClient = new SmtpClient(smtpServer))
                {
                    smtpClient.Send(mailMessage);
                }
            }
        }

We have multiple options while sending meeting requests. For example “X-MICROSOFT-CDO-BUSYSTATUS:FREE” will set the user state to free even user accept the meeting request. Hope this will help.


Friday, April 18, 2014

SharePoint - Back to basics - Display data in groups and sorting in SharePoint data grid view

We can use data view web parts to display data for adding different feature to show our list data. We can display groups and sorting by using data grid view web part. By using grouping sorting options in grid view we can display the item group wise

To add Data View web part to SharePoint page open SharePoint page in designer and in insert tab click on Data View Web part. Add Empty data view web part to the page.



Select the list to add the data view web part by clicking on “Click here to select data source” link in the web part.



We can see the pop up with all the lists in the site. Select the list.


In the right side pane, select multiple view to see all the items in the web part.


We can add/remove the columns to the web part by click on “Add or Remove columns” in the top ribbon. We can sort and group the data by clicking the “Sort and Group” option in top ribbon.



By clicking on the “Sort and Group” option we can see a pop up to add sorting and grouping columns.  We can have the options to collapse and expand the grouping in “Group Properties” section. Also we can edit the sort expression to display the items.



By checking “Sort & Filters on headers” we can provide sorting and filtering options as regular list columns. We can add Grouping tool bar for data view web part by selecting the options tab as shown in the image below.




After all we can see the data with grouping and sorting. 

Thursday, April 10, 2014

SharePoint 2013 wsp upgrading error: Cannot uninstall Language Pack 0 because it is not deployed when attempting to uninstall-spsolution.

While updating a wsp in SharePoint 2013 environment I got an error saying that “Cannot uninstall Language Pack 0 because it is not deployed when attempting to uninstall-spsolution.” As shown the image below.



By checking the solution in farm solutions (Central Administration -> System Settings -> Manage Farm Solutions) Solution wasn’t deployed. I have found this blog explaining the issue. The reason for this error is that DLL’s in the GAC were not able to delete. So I have deleted the DLL’s in the GAC and deployed through SharePoint central Administration

If it is timer job, We have to Stop and SharePoint timer services in the services.

Hope this helps.


Tuesday, April 8, 2014

SharePoint Usage and Health Data Collection Error - “There is no data available for this report. Here are some possible reasons - Web Analytics has not been enabled long enough to generate data”

While checking the usage health reports for a SharePoint site, I got an Error Saying that “There is no data available for this report. Here are some possible reasons: (1) Web Analytics has not been enabled long enough to generate data; (2) There is insufficient data to generate this report; (3) Data logging required for this report might not be enabled; (4) Data aggregation might not be enabled at the level required for this report.

After checking that one by one in the issues
  • I am having full of data in SharePoint site and that is fair enough to generate the data reports.
  • In the site I am sure that Data logging and Data Aggregation are enabled. I was checked that also as part of trouble shooting. Web Analytic are also enabled as mentioned in the issue.

After pulling hair and digging into the deep, I have found that Usage and Health Data Collection Service Application Proxy has not been started. Silly, but I have spent so much of my time. After starting the service proxy by using following Power Shell command everything working as expected.

$usageHealthDataServiceProxy = Get-SPServiceApplicationProxy | where {$_.DisplayName -eq “Usage and Health Data Service”}
$usageHealthDataServiceProxy.Provision()

Hope this helps.


Tuesday, March 18, 2014

Upgrade SharePoint 2010 classic mode web application to SharePoint 2013 claims mode using PowerShell commands

While working with SharePoint 2010 to 2013 migration I have to migrate SharePoint 2010 classic mode 2013 claims mode because we don’t have classic mode in SharePoint 2013. To do that I have upgraded SharePoint 2010 site to use claims mode authentication using PowerShell commands and restored the DB in SP 2013 server.

Now I ran: Test-SPContentDatabase” command to check the upgrade status. I got an error saying that there is inconsistency between the authentication modes. So I have reverted the claims mode authentication web app to classic mode and created a Web application in SharePoint 2013 using classic mode using following command

New-SPWebApplication -Name "Web application name" -ApplicationPool " Web application AppPool" -AuthenticationMethod "NTLM" -ApplicationPoolAccount (Get-SPManagedAccount "Application Pool account") -Port Port Number -URL "URL of the web application"

Now I took the classic mode SP 2010 web application backup and restored in SP 2013 web application. By running “Test-SPContentDatabase” command I got no issues. Now mount the database using “Mount-SPContentDatabase” command

Mount-SPContentDatabase ContentDB Name -DatabaseServer DBServerName -WebApplication Web Application URL

Finally we have to convert the web application from classic mode to claimant mode by using “Convert-SPWebApplication” command

Convert-SPWebApplication -Identity "WebApp URL" -To Claims –RetainPermissions -Force

Wednesday, January 29, 2014

SharePoint search error “SharePoint item being crawled returned error when attempting to download the item”

While working with SharePoint, I got an error in search service when I try to index a page having search results using for roll the content in site collection. My search service application and content source are working fine. After checking this error in logs and digging in to this error I found that we have to change User agent value.
To do that,

Open Registry editor (Run -> regedit) and navigate to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Global\Gathering Manager” key.



Change the value of “User Agent” from “MSIE 4.01” to “MSIS 8.0” and restart SharePoint search service.

Monday, January 27, 2014

Hit counter for SharePoint site

Generally few of blog sites I have checked the hit counter to count the number of hits for that site. For my blog also we can see the hit counter on the right bottom showing like the image below.


So Is there any feature or anything is available in SharePoint. Yes we have same kind of feature in SharePoint to view number of hits for specific page. By default it is available in SharePoint 2007 as explained in the URL here.

SharePoint 2010 we don’t have that feature. But we have a WebPart available in codeplex to achieve this functionality. We can download the file from codeplex.

But before adding this WebPart to our site, we have to create custom list as Statistics with URL (Multiple lines of text), Date (Single line of text), and Username (Single line of text) fields and provide contribute permissions for visitors and viewers group. So that all the visits will be listed. Hope it will help.

Sunday, January 26, 2014

Code Access Security in SharePoint web parts

Installing SharePoint web part dll files in GAC can cause some security implications. By default all the web parts will be installed in the GAC with full trusts. We can install web parts in web application dedicated bin folder. Web parts in bin folder will run in partial trust and will have only limited access to the bin folder.

If web part needs additional permission levels, we need to create custom CAS policies with permissions. By adding custom policies we can make the code to run in full trust and all the code will run with full trust without depending on the location where it installed.

Code accessibility Security (CAS) is a policy that limits the access to an assembly, System resources and operations. By default SharePoint will have built-in policies from ASP.NET, it will use minimal set of permissions to protect the server and infrastructure from vulnerable code. If web part needs greater access will have minimal settings and there are number of  ways that we can increase the permissions of the web part by creating custom CAS policy and increasing the overall trust level for the server farm in the web.config.

We can have WSS_UserCode, WSS_Minimal, WSS_Medium Built-In security settings in SharePoint foundation inheriting from ASP.NET trust levels. By default this built-in SharePoint Foundation policy files located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\CONFIG directory named wss_usercode.config, wss_minimaltrust.config and wss_mediumtrust.config.

By default SharePoint foundation will have WSS_Minimal trust level. This will supports all the permissions in the ASP.NET minimal trust. WSS_Minimal policy will restrict accessing all the web parts from advanced operations.  WSS_Medium level allows accesing SharePoin object model and file operations. This will also allows to access to environment variables.
We can check security policies in web.config file as

<securityPolicy>
<trustLevel name="WSS_Medium" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_mediumtrust.config" />
<trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_minimaltrust.config" />
</securityPolicy>

We can add custom files to SharePoint and add the tag to in Security policy tag as

<trustLevel name="WSS_Custom" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_custom_wss_minimaltrust.config" />

Sunday, December 15, 2013

Correlation Tokens in SharePoint workflow

Correlation tokens are unique identifiers in SharePoint that bridges to map the objects between the workflow and windows workflow environment. Windows workflow acts as a intermediate layer to communicate with other software. When incoming request arrives, runtime receives the request and determines the request and identifies the workflow instance. Then it process the request for the instance.

Windows workflow acts as a communication channel for all the workflow instances. We can have two separate correlation tokens for Workflows and task references. We cannot assign the correlation token to workflow task that used for workflow.

We have to declare the correlation token for the workflow in OnWorkflowActivated activity. We have to bind the this correlation token to  each activity in the workflow.
OnWorkflowActivated activity raises when workflow initiated  for SharePoint. This is the first event raised in workflow. Each task should have its own correlation token that provides the task related information. 

Tuesday, December 10, 2013

ViewFormPagesLockDown feature in SharePoint

In General by enabling the anonymous access in SharePoint site, anonymous users will have read-only access to the site. But when we enable anonymous access to SharePoint publishing site, we can have issues with anonymous users in SharePoint site due to ViewFormPagesLockDown feature. This feature will block users to view list view pages. Users can able to access all other web pages. Generally we can face this issue whenever users wanted to comment a blog post as anonymous in SharePoint blog site located in SharePoint publishing site collection.

We can check the ViewFormPagesLockDown feature is active or not by using following Power Shell command.

get-spfeature –site SiteURL


Here SiteURL is URL of the Site to check ViewFormPagesLockDown feature is active. By entering this command we can the list of features that are active in SharePoint site.
By disabling ViewFormPagesLockDown feature we can set anonymous users to access list view pages. to disable that we have to run following PowerShell commands

$lockdownFeature = get-spfeature viewformpageslockdown
disable-spfeature $lockdownFeature SiteURL



here SiteURL is URL of the site to disable ViewFormPagesLockDown feature. By disabling this feature anonymous users can access list view pages as usually.

Monday, December 9, 2013

Configure Web Part page security in SharePoint

In SharePoint webparts are the reusable sections in a SharePoint web page. We can add the functionality to SharePoint site by customizing webparts. We can connect the links to one WebPart to another WebPart by using WebPart connections.

We can manage the security of webparts from SharePoint central administration. To manage the security, Navigate to Security section in SharePoint central Administration, Click on Manage Web Part security link in General security section.


Select web application in Security for Web Part Pages page, Web Application section. In “Web Part Connections” section, we can specify the users to allow the connections by passing data or values from a source Web Part to target Web Part. By Selecting “Allow users to create connections between Web Parts” option we can allow people to create the connection. By Selecting “Prevents users from creating connections between Web Parts, and helps to improve security and performance”

In Online Web Part Gallery section, we can specify users to access the online Web Part gallery. By Selecting “Allow users to access the online Web Part Gallery” option we can allow users to access the online WebPart.

We can allow the scriptable webparts by specifying “allow contributors to add or edit scriptable Web Parts” option in Scriptable Web Parts section. Click on Ok to save the settings


Thursday, December 5, 2013

Content Iterator in SharePoint

In SharePoint object model while getting the data from large lists through SPQuery, we can get SPQueryThrottleException saying that “The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator”. We can get rid of this exception by using Content Iterator (CI). Content Iterator provides implementation interface for SharePoint objects to regularize the amount of data to be transferred. This will helps queries in on the lists to not put the load on database excessively. It will iterate the content in the list instead of executing the query. So that it will process each item in the list to avoid the throttling limits.

We can process the content iterator to crawl the list items. Following is the sample code will give us the detail about Content Iterator processing

public static void ProcessListItems(SPWeb site)
{ 
string iteratorName = "item iterator"; 
ContentIterator iterator = new ContentIterator(iteratorName);

iterator.ProcessLists(site.Lists,
delegate(SPList list){ 
ContentIterator.EnsureFieldIndexed(list, list.Fields.GetFieldByInternalName("Title").Id);
string query = "<Where><And><BeginsWith><FieldRef Name='Title' /><Value Type='Text'></Value>RT</BeginsWith></And></Where>"; 
ContentIterator itemsIterator = new ContentIterator(iterator);
itemsIterator.ProcessListItems(list,query,true,
delegate(SPListItemCollection items){
foreach (SPListItem item in items){
ProcessItem(item);
}
},null);
},
delegate(SPList list, Exception e)
{
OnListException(list, e);
});
}



Wednesday, December 4, 2013

Retention stages for SharePoint 2013 Document library

In SharePoint Document library retention policies we can set the retention policy for Content type and library document and folders. By applying the retention policies to document library items we can make them delete or make them records with the existing options.

To set the retention policies for library items or folder we have to navigate library settings page and click on Information management policy settings link in Permissions and Management section.


In Information Management Policy Settings page click on Change Source link in Source of retention for this library.



Select Library and Folders option in “Source of Reflection” section. We’ll see a popup with warning message by selecting that option saying that “when library and folder based integration schedules will select, all the Content types will be ignored”, Click on Ok.


We can new section with “Library Based Retention schedule” with description text box. Click on Add a retention stage link to add new retention.




We can see new dialog box specifying the Event and action details. Select the Event and Action for retention stage and click on Ok to save the settings. We can add many retention stages for the document library. Click on Ok in Library Based Retention Schedule page to save the settings.

Thursday, November 28, 2013

Distribution lists in SharePoint

In SharePoint, we can manage the users by assigning the permission levels to groups. We can do that by setting up individual users of Active directory groups. We can do that in two ways using Security groups in site and using distribution groups.

A distribution group is used to send emails for not security-enabled users. We cannot list the distribution groups in discretionary access control list that are used to define the permissions. By selecting security groups users will not be accessible to my sites. User groups will be dedicated to only a specific site.

We can create SharePoint distribution groups by navigating security and clicking on the Approve or reject distribution groups in Users section.



Create new Item in the distribution group by clicking on new item link


Enter details of the item like group title, Alias name, Description, Owner Email details. Click on ok to save details. Here justification is message to the user who approves the requests in the distribution groups. We can see the requests in the list once it is approved.


Wednesday, November 27, 2013

Gantt view errors in SharePoint site- “Microsoft.SharePoint.SPException: This view requires at least Microsoft Internet Explorer 7.0, Mozilla FireFox 3.0, or Apple Safari 3.0.”

In SharePoint 2010, sometime we try to browse the gantt index pages, we can see the error as “Microsoft.SharePoint.SPException: This view requires at least Microsoft Internet Explorer 7.0, Mozilla Firefox 3.0, or Apple Safari 3.0.” as shown the image below.


We can get this error when user agents in SharePoint are not permitted to crawl the content in SharePoint index server. We can fix this by changing Gathering manager value in Registry. To do that Start -> Run -> Regedit


Navigate to following path,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Global\Gathering Manager


In Gathering Manager, Search for “User Agent” and edit the value. Update the value to
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; MS-RTC LM 8; Tablet PC 2.0)


Click on Ok Save the settings and restart the server.

Tuesday, November 26, 2013

Document information panel in SharePoint

Document information panel in SharePoint contains Meta data about document. This will enables users to enter metadata regarding the document. Documents stored in library will contain other columns to show metadata. Document information panel will display the field for each content type property or column that user can edit.
Document management panel allows users to enter metadata for Microsoft based documents that stored in SharePoint. This will not display by default with the document. We have show this by changing the settings for content type.

We can enable document information panel using the steps below,
Navigate to SharePoint Document library Settings page, Click on the content type which to enable Document Information Panel should be enabled.



Click on Document Information Panel Settings in settings section.



In Document Information Panel Templates section, we can specify the default template or custom template. Select “Always Show Document Information Panel on document open and initial save for this content type” Check-box in Show Always section, Click on OK to save the settings.



By editing the document uploaded to document library we can see the fields as shown below.



Monday, November 25, 2013

SharePoint user profile service error: An error was encountered while retrieving the service

While working with SharePoint user profile through code, I got an error when accessing the user profile from user profile manager. Stack trace has thrown the error as,  

Microsoft.Office.Server.UserProfiles.UserNotFoundException was unhandled
  Message=An error was encountered while retrieving the user profile.
  Source=Microsoft.Office.Server.UserProfiles

I have checked in User profile service that account crawled correctly or not. Yes it is there. Iam able to get the user in SharePoint user picker as expected. I have googled about the issue for some time. I have fixed the exception using an article from technet. Tip shown in the blog post fixed my error.

Actually iam getting the error from following code line 

UserProfile currentUser = profileManager.GetUserProfile("Domain\UserName")


Here profilemanager is UserProfileManager object. After changing “\” to “\\” in user profile my issue got fixed. I have replaced my code line with 

UserProfile currentUser = profileManager.GetUserProfile("Domain\\UserName")

Simple. Hope this will help you.