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.


Wednesday, March 26, 2014

SharePoint 2013 – Not able to see “Audit log reports” link in Site settings

In one of my previous article I have explained how to configure audit log reports in SharePoint environment. I got few comments that they are not able to see the “Audit log reports” link in site settings

By activating reporting feature we can add “Audit log reports” link to site settings. We can add “Audit log reports” link in site settings by using following steps

Navigate to SharePoint site settings page and click on Manage Site collection features in Site Administration section



Check for Reporting feature. Click on activate button to activate the feature.



Now we can Audit log reports link in Site Collection Administration section as shown below.


Monday, March 24, 2014

Upgrade workflow in SharePoint environment

While working with SharePoint workflows I have a scenario to upgrade the logic for workflow. But there are many items already running on the existing workflow. So new workflow shouldn’t override on existing. We need to create an upgrade for existing workflow.

TO do that we have to follow the steps below,
Change Workflow assembly version number by right clicking on the workflow project, In Application section, Click on Assembly Info button. Change Assembly Version number and file version number in Assembly information






















Update the assembly version number in workflow.xml file workflow element. Change the Solution ID in the manifest.xml file

Change .wsp name. For example we have Site.DataRequestWorkFlow.wsp previously, update it to Site.DataRequestWorkflowV1.wsp.

Deploy new wsp file using PowerShell commands or stsadm commands and we have to Run IISReset command


Change the old workflow to not allowing any new instances and disable the options to start manually or Item created. By doing this there will not any new instances for old workflow. Create a new workflow association using new workflow that deployed.

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

Monday, March 17, 2014

Update UserProfile properties in using SPServices in SharePoint

I got a requirement to update the User Profile properties for one of my client. We have only option to do that using SPServices because they are not allowing any server side code. In SPServices we can directly update the user profile services using “ModifyUserPropertyByAccountName” method. By passing current logged-in user account to the method we can update the user profile properties using SPServices. I have found the following code from here (http://azzu-sheikh.blogspot.in/2014/01/update-user-profile-property-through.html)to update the user profile service.

function updateUserProfileProperty(currentLoggedInUser, propertyName, propertyValue) {
   var propertyData = "<PropertyData>" +
  "<IsPrivacyChanged>false</IsPrivacyChanged>" +
  "<IsValueChanged>true</IsValueChanged>" +
  "<Name>" + propertyName + "</Name>" +
  "<Privacy>NotSet</Privacy>" +
  "<Values><ValueData><Value xsi:type=\"xsd:string\">" + propertyValue + "</Value></ValueData></Values>" +
  "</PropertyData>";

   $().SPServices({
       operation: "ModifyUserPropertyByAccountName",
       async: false,
       webURL: "/",
       accountName: currentLoggedInUser,
       newData: propertyData,
       completefunc: function (xData, Status) {
           var result = $(xData.responseXML);
           if (Status == "success") {
              //do update action
           }
       }
   });
}


We can change the user property details by getting property data in to the method and passing the current logged-in user account details as shown the code above.

Friday, March 14, 2014

Change SharePoint site time format


In SharePoint calendar by default we can see the view as Day/week in 12 hour format, not in 24 hour format. We can to change the format from 12 hour to 24 hour through UI or using PowerShell commands.

We can change that through UI by following steps,

Navigate to SharePoint Site settings page and in Site Administration section click on “Regional settings” link



In Time format drop down select 24 hour format. Click on ok to save the settings.


We can change the format using following Powershell commands,

$site = Get-SPSite <SiteCollectionURL>
$web = $site.OpenWeb()
$web.RegionalSettings.Time24=$True
$web.RegionalSettings.FirstDayOfWeek=1
$web.Update()
$web.Dispose()
$site.Dispose()


Wednesday, March 12, 2014

Check current logged-in user having permissions to specific group in SharePoint SPServices

We can check the groups for current logged-in user from SPServices code using “GetGroupCollectionFromUser” opration. Before the we have to download and add folowing files. Javascript 1.7.1.js and JQuery.SpServices-0.7.1a.min.js

Following script will used to get the user group details

$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
var count = 0;
$(xData.responseXML).find("Group").each(function () {
if ($(this).attr("Name") == "Group Name") 
count++; 
}
 }); 
if (count == 0) {
// do some action
}
else {
// do some action
}
}
});

Tuesday, March 11, 2014

Change default home/welcome page in SharePoint site using PowerShell commands

We can change SharePoint default home page in different ways as using Site settings if publishing feature already enabled, SharePoint object model code, Using SharePoint designer and PowerShell commands.
We can change the home page by running following PowerShell commands,

Get the Site details by using Get-SPSite command and web by using OpenWeb() method.

$objSite = Get-SPSite SiteURL
$objWeb = $objSite.OpenWeb(“Sub site”)

Get the root folder for the web by using RootFolder property

$rootFolder = $objWeb.RootFolder

Change the home page by assigning Welcomepage property as shown below

$rootFolder.Welcomepage = “SitePages/SureshHomePage.aspx
$rootFolder.update()

After updating the page, we have to dispose the site and web objects because that objects are created newly.

$objWeb.dispose()
$objSite.dispose()

By combing the all the commands we can see the script as

$objSite = Get-SPSite SiteURL
$objWeb = $objSite.OpenWeb(“Sub site”)
$rootFolder = $objWeb.RootFolder
$rootFolder.Welcomepage = “SitePages/SureshHomePage.aspx
$rootFolder.update()
$objWeb.dispose()
$objSite.dispose() 

Sunday, March 9, 2014

SharePoint content search web part – Show items sorted by Modified date

Working with SharePoint 2013, I got a requirement from client to implement a search query web part. We have to display the items depending on the modified date. Everything in my content search web part is working as expected. But I am unable to see items modified today.

I have started full crawl again but results are not showing as expected. By checking the Content Search Web part settings, in sorting section we can see the field for date modified as “lastModifiedTime” applied the search filter. I got same results as earlier.

After digging into deep, instead of changing out of box settings, created new one in SharePoint search with Name Modified as shown image below.



Creating the search, started SharePoint full crawl and In Content Search Web part settings, changed Modified managed property.


Super, It worked for me. Now I am able to see the items in CSWP in sorting order.

Saturday, March 8, 2014

SharePoint 2013 Exception “Unknown exception occurred while executing a SharePoint solution”

In SharePoint 2013 adding Sandboxed solution I got an error as “Unknown exception occurred while executing a SharePoint solution” as shown blow.


By checking the ULS logs, I have found the following text as “An unknown exception occurred while executing a sandboxed code solution request in the worker process.\r\n|0 – userCodeWrapperType.FullName = “Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper”

I have checked by changing the application pool identity, checked sandboxed service is running is not. But still I am getting the same error. My current running server is a standalone server with Windows Server 2012, Domain Controller, SQL Server 2012, SharePoint 2013, and Visual Studio 2012.


By digging this into deep, found that there is no fix for this issue, we have to create the new environment. By enabling verbose logging for Sandboxed code solution it will give us temporary fix but not permanent.