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

Sunday, August 10, 2014

SharePoint 2013 search refinement web part

One of the most powerful web parts in SharePoint 2013 to provide search refinement experience is Search refinement web part. Search refinement web part allows users to select to refine their search results to be list a subset of results. We can modify this web part to include the properties to be appear as refiners in the search results page and also we have the option to choose the appearance of the properties like single or multiple. Depending on the data returning on the search results web part, we have the advantages to choose metadata values to be displayed. For example in a Office Management Search center, we have data to be displayed custom metadata such as Employee Job type, Designation, Department and some other default information like author details.

As shown the image below, we can see the configuration details in SharePoint Search refinement web part.




Issue with SharePoint custom workflow delay activity

While working with SharePoint custom workflow delay activity, Iam not able to run the code in delay activity. I have deleted and added new delay activity but it wasn’t worked. In general we can add user input after a particular time, we can go with delay activity in SharePoint custom workflow.

Delay activity is broken in SharePoint 2007 as well as SharePoint 2010. To fix that we have to run stsadm commands below,

stsadm -o getproperty -pn job-workflow -url siteURL

stsadm -o setproperty -pn job-workflow -pv “Every 2 minutes between 0 and 59″ -url siteURL

After running the commands, we have reset IIS and Restart the timer services in Server.

Hope this will helps.

Saturday, July 26, 2014

SharePoint migration – designer workflow runs twice every time

Migrating from SharePoint 2007 to 2013, SharePoint designer 2007 workflows migrated correctly and workflows are working as expected.

We can’t use SharePoint 2007 list template directly to create the list templates. To do that we have to save the list as a template and need to use that template to create the list.

In SharePoint 2007 site we had a workflow that sends email and update the list data depending on the details created/updated. I have attached the SharePoint designer workflow to the list. But after attaching the workflow, whenever list item added/updated to the list, it is firing twice.

After checking that some time and trail and errors I got the fix for the problem. To do that we have to pause some duration in the workflow beginning. We can make this as 1 min because the workflow timer job will take 5 min and by updating the ‘pause for duration’ value we can change the value by using job definitions in Central Administration.


Thursday, July 24, 2014

SharePoint Managed Accounts error: Managed Account could not be deleted because other objects depend on it.

After deleting all the service applications and managed account from SharePoint server by using following PowerShell commands,

Get-SPManagedAccount | Where-Object {$_.UserName -eq "Domain\Username"} | Remove-SPManagedAccount

By running the command I got an error saying that,

Remove-SPManagedAccount : An object in the SharePoint administrative framework, “SPManagedAccount Name=managed-account-S-1-5-21-2912393494-653453454-43454533245-4324″, could not be deleted because other objects depend on it. 

We can see this error because the service error we are going to delete is having dependencies. In my case iam using same account for User Profile Service.

By using following commands, we can release the dependencies on the service account.

Get-SPServiceApplicationPool | Where-Object {$_.Name -eq "User Profile Service"} | Remove-SPServiceApplicationPool

After running the command we have to delete the account by running the following command,

Get-SPManagedAccount | Where-Object {$_.UserName -eq "Domain\Username"} | Remove-SPManagedAccount


Hope this helps.

SharePoint – Delete Orphaned sites using PowerShell commands

We can delete the orphaned site in SharePoint environment that we are trying to provision the project server application. To remove orphaned site we have to un-provisioned and then delete the site.

We can delete the site by using following PowerShell commands,

Get SharePoint service application by using Get-SPServerviceApplication command
We can see the list of GUID’s. Get the service application specific to the orphaned site by using get-spserviceapplication command

$serviceApp = Get-SpServiceapplication | ? {$_.Id -eq "GUID of the Service App"}

Get the Site collection by using the service app

 $siteCollection = $serviceApp.SiteCollection

Get the site from Site Collection and delete the site by using the following commands,

$site = $siteCollection.Sitecollection | where {$_.SiteID -eq "< Guid>"}
$site.Delete()


Wednesday, July 16, 2014

SSRS report – SharePoint list error: an error occurred when accessing the specified SharePoint list. The connection string might not be valid

While creating the report by using SharePoint list, I got an error saying that “an error occurred when accessing the specified SharePoint list. The connection string might not be valid” as shown the image below.



I have checked all the possibilities for the error by changing the credentials in the report. It didn’t worked for me. Changed the connection string URL. Restarted BI development studio and Restarted Reporting services and finally restarted the machine too... No luck. L
By checking more than half day I have found the cause. The reason is, I have changed my VPN password recently and disabled UAC in my machine. So by connection the site, it is using my old password stored in windows vault.

We have to change the stored credentials in windows vault by using the steps below,
Navigate to Windows vault and in Windows credentials section select the site and update the credentials.




Now Iam able to access the list from SharePoint list  

Saturday, July 5, 2014

PowerShell Commands: Download files/documents from SharePoint document libraries

In SharePoint 2013 we have an option to sync all the data from SharePoint document libraries to local folders by using Shared drive concept. We can download the document s from SharePoint document library using Power Shell commands also. We can do that in overall site collections and all the site collection may contain loads of documents and downloading one by one is a huge task by using windows explorer.

To download the document we can use following script,

$listUrls="Doc lib 1 URL″,” Doc lib 2 URL ″,” Doc lib 3 URL ″," Doc lib 4 URL ″ (All the document libraries URL’s)
#Enter the web site URL

$web = Get-SPWeb -Identity $webUrl

#Load all the list URLs in the web, Open the list URL.

foreach($listUrl in $listUrls)
{

#get the list URL

$list = $web.GetList($webUrl+”/”+$listUrl)

function DownloadDocuments{
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {

       
#Ensure destination directory

        $destinationfolder = $destination + “/” + $folder.Url
        if (!(Test-Path -path $destinationfolder))
        {
            $dest = New-Item $destinationfolder -type directory
        }

       
#Download file

        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + “/” + $file.Name)
        $writer = New-Object System.IO.BinaryWriter($stream)
        $writer.write($binary)
        $writer.Close()
        }
}

#Download root folder documents

DownloadDocuments ($list.RootFolder.Url)
foreach ($folder in $list.Folders) {

#download all the documents in each sub folders

   DownloadDocuments($folder.Url)
}


Monday, June 23, 2014

Display loading image in SharePoint using JavaScript

To display loading image in SharePoint site We have to download the image and save it as Loading.gif and save it in SharePoint document library. Select list new item page and to be and edit the page.

Add Content Editor Web part to the page. Enter following script to the page.

<script src="../Library/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>

<style type="text/css">
   #loadImage {display:none;}
</style>

<script type="text/javascript">
function PreSaveItem()
{
  $("# loadImage ").css("display", "block");
    if ("function" == typeof (PreSaveAction)) {
        return PreSaveAction();
    }
    return true;
}
</script>

<div style="padding-top: 25px; padding-left: 30px;">
   <img width="250" height="250" id="loadImage" src="/Site/images/Loading.gif" alt=""/>
</div>

Save and close the page. Here src is the image to be loaded and enter the padding. We can see the image when page loading as shown below.


Function will be called on the List item Save event. 

Wednesday, June 11, 2014

Display PowerPoint Presentation in SharePoint 2013 page

We can allow users to view Office web apps in SharePoint 2013 with in the browser by clicking on the link of document. We can display PPT in browser. First of all create and upload a PPT to document library by selecting New Document, Select “PowerPoint Presentation” as shown the image below.



Select the PPT URL by clicking on the … next to PPT document, select and copy the URL. Navigate to the page where we need to display the PPT and insert Page viewer web part as shown below.



Edit the web part, enter the URL in Page Viewer link in web part properties. In Appearance tab select “YES” for “should the web part have a fixed height”, and set it as 600 px. Save and close the properties.



Now we can see the PPT in the page as a web part and will have options to navigate the pages in PPT.

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.

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 26, 2014

SharePoint 2013 feature deployment error: Failed to get the list schema XML for feature in GetUserListSchema()

While deploying SharePoint solution I got an error saying that

Error occurred in deployment step ‘Activate features’: Cannot complete this action. By checking the error in logs I have found the exception details as

GetUserListSchema(): Failed to get the list schema XML for feature

By digging into the issue I have found that there is some scope activation details we are unable to deploy this feature. In the code I have added a list definition and list template associated to that list definition. I have added a new feature scoped with site and moved List definition feature to that. So here I have changed the List definition scope from web to Site and kept list template on the same scope. While deploying the feature I got the error on that.

To fix this issue we have to edit the list instance elements.xml file and need to update the list definition feature id in elements.xml file.  
We can update the list inastance elements.xml as

  <ListInstance Title="Name of the list instance"
                TemplateType="10000"
                FeatureId="List definition Feature ID"
                Url="Lists/InstanceName"
                Description="List instance description">
  </ListInstance>



By updating the feature id, Iam able to deploy the solution without issues. Hope this helps.

SharePoint – Back to basics- Creating lists using excel by using Import spread sheet template

We can create SharePoint list using Excel sheet using Import Spreadsheet Template. As a Developer\Administrator we can have knowledge on how to create the lists and libraries. But End users will not aware of this. For this purpose we have an option to create the list by using excel sheet having data.

To create using Excel sheet we have an option “Import Spreadsheet” as shown the image below.



While creating the list, Select “Import Spreadsheet” option. By selecting the option we’ll be navigated to details form page as below. Enter Name and description for new list and browse the Excel sheet in File location. Click on Import Button to update the data to select the data from the list.



Once user importing the data, list will be created with all the existing columns in sheet. Sometime SharePoint will not identify the type column. That’s only disadvantage with this option
Hope this helps.


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.


SharePoint 2013 Reporting Service Applications – Enable Remote errors for a Reporting services Service Application

We can enable remote errors in for report services installed through SQL Server 2012 in SharePoint or newer versions of reporting services. To enable the service applications we have to set Enable remote error. This will be configured for all the report service applications. To do that we have to follow the steps below,

Navigate to SharePoint central Administration, click on manage service application in Application management section


Select the Service Application in the list of service Applications and Click on the name of Service Application
Click on the System Settings. In Security Section Select "Enable Remote Errors" and click on Ok to Save the Settings.


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.


Thursday, April 3, 2014

SharePoint Power view error: There are no addresses are available for this application

Working with SharePoint power view I got an error saying that “Microsoft.SharePoint.SPEndpointAddressNotFoundException: There are no addresses available for this application.”

Checking the error I have found that we have to run SQL Server Reporting service, Manage metadata service and user profile services. We have to make sure that they are running properly. To do that navigate to SharePoint Central Administration, Application Management section. Click on Manage Services



Check for SQL Server Reporting service, Managed meta data service and User profile services are started or not. If not started Start the services. Reset IIS manager (IISRESET)


Friday, March 28, 2014

SharePoint workflow deployment issue: Error occurred in deployment step ‘Activate Features’, Unable to locate workflow association data

While deploying with SharePoint workflow I got an error saying that “Error occurred in deployment step 'Activate Features': Unable to locate the workflow's association data. To restore the association data to the workflow, restart the workflow settings wizard by selecting the workflow node in Solution Explorer and then clicking the ellipsis button (…) on one of the properties in the Properties window that has an ellipsis button

Workflow is combination of events like task creation, Task updating and completion. By adding a workflow to the site, we have to specify the task list and history lists. Instances of task list and history list will track the events for workflow. Task list allows users to interact with workflow and history list contains information about the workflow events including date, status, participant etc.

While creating a new workflow visual studio will associate the lists. Some cases association will goes away whenever we change or delete the workflow designer file, we can get association error. To fix this error we have to set “Auto Associate” property to ‘false’ in workflow properties.



 By deploying the workflow now workflow will deploy without any issues and user will manually go and create the associations instead of automatic associations.