When I'm developing software I often have Fiddler turned on to capture client HTTP traffic. I've noticed weird http://server/Analytics_{GUID}/ Requests appearing in a batch of 4 requests every minute:
Investigation led me to Application Server Administration Service Timer Job which in turn called Search Service Instance's Synchronize method. This method calls code which uses rather odd way of determining whether file share exists:
private static bool ShareExists(string path)
{
try
{
Directory.GetDirectories(path);
return true;
}
catch (UnauthorizedAccessException ex)
{
return true;
}
catch (Exception ex)
{
return false;
}
}
Line Directory.GetDirectories(path); causes those 4 requests. This execution path happens when you don't have Search Service Application provisioned but you do have SharePoint Server Search service started.
Anyway, I stopped the service using cmdlet:
Get-SPEnterpriseSearchServiceInstance -Local | Stop-SPEnterpriseSearchServiceInstance
And the problem was solved, no more pesky Analytics requests.
Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts
2018-10-24
2016-12-14
Setting Related Item on a SharePoint 2013 Worfklow's SingleTask
Sometimes when we design workflows it is necessary to set related item in SingleTask to something different than the default listitem. Default list item is the item on which workflow was started. So, lets say we start workflow on doc1.docx. Inside the workflow we define SingleTask. This SingleTask, when opened in SharePoint UI, will have, by default, a link to doc1.docx. Sometimes we would like this SingleTask to have related item which is different than that particular doc1.docx.
Microsoft has intended for this purpose SingleTask argument named RelatedContentLinkListItemIntegerId. Great, you just set the list ID and item ID and you have your problem solved. Wrong!! Setting this property will have no impact on related item. At least, not if you use default generated SingleTask activity.
The solution:
Setting RelatedContentLinkListItemIntegerId will only work if you delete a particular child element in workflow markup (XAML). So, first open your workflow in Code mode (Visual Studio View Code - F7). Then locate the SingleTask activity which you would like to configure. This should be p:SingleTask XML element. Delete p:SingleTask.RelatedContentLinkListItemId child elemet. Save your workflow and voila, it will change related item to whatever value you set it.
Microsoft has intended for this purpose SingleTask argument named RelatedContentLinkListItemIntegerId. Great, you just set the list ID and item ID and you have your problem solved. Wrong!! Setting this property will have no impact on related item. At least, not if you use default generated SingleTask activity.
The solution:
Setting RelatedContentLinkListItemIntegerId will only work if you delete a particular child element in workflow markup (XAML). So, first open your workflow in Code mode (Visual Studio View Code - F7). Then locate the SingleTask activity which you would like to configure. This should be p:SingleTask XML element. Delete p:SingleTask.RelatedContentLinkListItemId child elemet. Save your workflow and voila, it will change related item to whatever value you set it.
2016-05-02
OpenQuery Failed with status ID: 0x800007d0
ULS on my clients' farm was polluted by messages "OpenQuery Failed with status ID: 0x800007d0" every few seconds.
Turns out I had to add user which is running mssearch.exe process (SP_Search in my case) to local group called Performance Monitor Users. After adding the user I rebooted the machine and the problem went away.
Turns out I had to add user which is running mssearch.exe process (SP_Search in my case) to local group called Performance Monitor Users. After adding the user I rebooted the machine and the problem went away.
2016-02-17
Shared Folder Permissions When Running Backup-SPFarm
I have setup a farm according to Medium Security Option on Vlad Catrinescu's blog. I setup a backup of this farm using Backup-SPFarm powershell script. If I grant read/write permissions to Everyone on shared folder everything works fine. But if I limit permissions only to SP_Admin account backup fails.
The solution is to grant the following accounts read/write permissions to shared folder:
where SP_Admin is the user account which executes the script.
The solution is to grant the following accounts read/write permissions to shared folder:
- SP_Admin
- SP_Services
- SQL_Services
where SP_Admin is the user account which executes the script.
2015-12-22
NullReferenceException When Clicking a Task in Workflow Designer
The other day I was designing a Workflow (Workflow Manager technology) in Visual Studio 2012 when I stumbled upon on an exception when clicking on a SingleTask activity in Workflow Designer within Visual Studio. When I first click on a task I get "Communicating with SharePoint" dialog:
After Visual Studio establishes communication with SharePoint I end up with the following dialog:
Full exception stack trace is as follows:
-------------------------
Workflow Designer
-------------------------
NullReferenceException:
Object reference not set to an instance of an object.
-------------------------
Server stack trace:
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointSolutionModelStorage.GetAllFiles(ISharePointProject project)
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointSolutionModelStorage.Refresh(ISharePointProject project)
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointCompositeModelStorage.RefreshProjectModels()
at Microsoft.VisualStudio.SharePoint.WorkflowDesignerSupport.ListInfoService.GetContentTypes(String BaseTypeId)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.<GetWorkflowTaskContentTypes>b__10(IListInfoService service)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.ConvertValues(Func`2 producer)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.GetWorkflowTaskContentTypes()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.SharePoint.DesignTime.Activities.Design.Services.ISharePointListService.GetWorkflowTaskContentTypes()
at Microsoft.SharePoint.DesignTime.Activities.Design.ContentTypesProvider.ProvideItems(ISharePointListService service)
at Microsoft.SharePoint.DesignTime.Activities.Design.IndependentDataProvider`1.GetItems(ModelItem owner, PropertyValue propertyValue)
at Microsoft.SharePoint.DesignTime.Activities.Design.SharePointItemChooserViewModel`1.GetItems(ModelItem Owner, PropertyValue PropertyValue)
at Microsoft.SharePoint.DesignTime.Activities.Design.ChooserViewModel`1.PopulateItems()
at Microsoft.SharePoint.DesignTime.Activities.Design.GenericChooser`2.SharePointBaseChooser_Loaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.RouteItem.InvokeHandler(RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.EventRoute.InvokeHandlers(Object source, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
-------------------------
After a long debugging session of Workflow Designer I realized that my colleague accidentally deleted Package folder from SharePoint App project. I pulled the latest version and I didn't notice that folder was missing. When I restored the folder, Workflow Designer didn't throw any exceptions any more.
After Visual Studio establishes communication with SharePoint I end up with the following dialog:
Full exception stack trace is as follows:
-------------------------
Workflow Designer
-------------------------
NullReferenceException:
Object reference not set to an instance of an object.
-------------------------
Server stack trace:
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointSolutionModelStorage.GetAllFiles(ISharePointProject project)
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointSolutionModelStorage.Refresh(ISharePointProject project)
at Microsoft.VisualStudio.SharePoint.Designers.List.ModelAccess.SharePointCompositeModelStorage.RefreshProjectModels()
at Microsoft.VisualStudio.SharePoint.WorkflowDesignerSupport.ListInfoService.GetContentTypes(String BaseTypeId)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.<GetWorkflowTaskContentTypes>b__10(IListInfoService service)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.ConvertValues(Func`2 producer)
at Microsoft.VisualStudio.SharePoint.WorkflowExtensions.SharePointListService.GetWorkflowTaskContentTypes()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.SharePoint.DesignTime.Activities.Design.Services.ISharePointListService.GetWorkflowTaskContentTypes()
at Microsoft.SharePoint.DesignTime.Activities.Design.ContentTypesProvider.ProvideItems(ISharePointListService service)
at Microsoft.SharePoint.DesignTime.Activities.Design.IndependentDataProvider`1.GetItems(ModelItem owner, PropertyValue propertyValue)
at Microsoft.SharePoint.DesignTime.Activities.Design.SharePointItemChooserViewModel`1.GetItems(ModelItem Owner, PropertyValue PropertyValue)
at Microsoft.SharePoint.DesignTime.Activities.Design.ChooserViewModel`1.PopulateItems()
at Microsoft.SharePoint.DesignTime.Activities.Design.GenericChooser`2.SharePointBaseChooser_Loaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.RouteItem.InvokeHandler(RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.EventRoute.InvokeHandlers(Object source, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
-------------------------
After a long debugging session of Workflow Designer I realized that my colleague accidentally deleted Package folder from SharePoint App project. I pulled the latest version and I didn't notice that folder was missing. When I restored the folder, Workflow Designer didn't throw any exceptions any more.
2015-09-09
Updating Workflow Definitions Without Terminating Current Instances
I haven't seen anywhere a good tutorial on how to update a workflow definition without terminating currently running instances on SharePoint 2013 Workflow Manager platform so this post is my contribution to the community. The goal of this post is to enable the following series of steps:
There are some examples on how to update Workflow Manager workflows on MSDN but these examples are strictly tied to Workflow Manager platform, not Workflow Manager in combination with SharePoint 2013. My solution is based on aforementioned MSDN article but it is adapted to SharePoint 2013.
Prerequisite for my solution is at least one deploy of the workflow using either Visual Studio deploy or using PowerShell scripts. Workflow needs to be deployed as a part of the feature only first time.
For part 1 of this post I will demonstrate how to publish new versions of workflow using console application. I also presume you are developing on development box with Visual Studio installed. In part 2 I will focus on packaging the deployment in feature receiver.
Complete solution is available for download.
List of types in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.SharePoint.DesignTime.Activities.dll assembly:
- Update workflow definition XAMLs (for example from version 1 to version 2).
- Allow currently running instances of workflow to finish running the version 1 of the workflow.
- New instances of workflow will run version 2 of the workflow. Version 1 of the workflow shouldn't be allowed to run any more.
There are some examples on how to update Workflow Manager workflows on MSDN but these examples are strictly tied to Workflow Manager platform, not Workflow Manager in combination with SharePoint 2013. My solution is based on aforementioned MSDN article but it is adapted to SharePoint 2013.
Prerequisite for my solution is at least one deploy of the workflow using either Visual Studio deploy or using PowerShell scripts. Workflow needs to be deployed as a part of the feature only first time.
For part 1 of this post I will demonstrate how to publish new versions of workflow using console application. I also presume you are developing on development box with Visual Studio installed. In part 2 I will focus on packaging the deployment in feature receiver.
- Create new console application (.NET 4.5) project
- Add the following references to the project (not all are needed, but I didn't filter out unneeded references):
- Add WorkflowManagementClientExtensions class to the project:
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------ using Microsoft.Activities; using Microsoft.Activities.Messaging; using Microsoft.Workflow.Client; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading; namespace Microsoft.Workflow.Samples.Common { public static class WorkflowManagementClientExtensions { public static void PublishActivity(this WorkflowManagementClient client, string name, string xamlFilePath) { client.Activities.Publish( new ActivityDescription(WorkflowUtils.Translate(xamlFilePath)) { Name = name }); } public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, xamlFilePath, null, null, activationFilter); } public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, Collection<ExternalVariable> externalVariables, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, xamlFilePath, externalVariables, null, activationFilter); } public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, IDictionary<string, string> configValues, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, xamlFilePath, null, configValues, activationFilter); } public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, Collection<ExternalVariable> externalVariables, IDictionary<string, string> configValues, SubscriptionFilter activationFilter = null) { // publish the activity description related with the workflow client.Activities.Publish( new ActivityDescription(WorkflowUtils.Translate(xamlFilePath)) { Name = workflowName }); // now, publish the workflow description WorkflowDescription description = new WorkflowDescription { Name = workflowName, ActivityPath = workflowName, }; // add external variables if (externalVariables != null) { externalVariables .ToList() .ForEach(ev => description.ExternalVariables.Add(ev)); } // add config if (configValues != null) { description.Configuration = new WorkflowConfiguration(); configValues .ToList() .ForEach(c => description.Configuration.AppSettings.Add(c)); } // add activation filter if (activationFilter != null) { description.ActivationDescription = new SubscriptionActivationDescription { Filter = activationFilter }; } // publish! client.Workflows.Publish(description); } public static void CleanUp(this WorkflowManagementClient client) { client.CurrentScope.Delete(); } public static string WaitForWorkflowCompletion(this WorkflowManagementClient client, string workflowName, string instanceId, int pollingInterval = 0) { string currentStatus = string.Empty; string lastStatus = string.Empty; WorkflowInstanceInfo instanceInfo = client.Instances.Get(workflowName, instanceId); while (true) { instanceInfo = client.Instances.Get(workflowName, instanceId); currentStatus = instanceInfo.UserStatus; if (currentStatus != lastStatus && !string.IsNullOrWhiteSpace(currentStatus)) { Console.Write(" Current Status: "); WorkflowUtils.Print(currentStatus, ConsoleColor.Cyan); lastStatus = currentStatus; } if (instanceInfo.WorkflowStatus == WorkflowInstanceStatus.Started || instanceInfo.WorkflowStatus == WorkflowInstanceStatus.NotStarted) { Thread.Sleep(pollingInterval); continue; } if (instanceInfo.WorkflowStatus == WorkflowInstanceStatus.Completed) { Console.WriteLine("\nWorkflow instance completed"); } break; } return instanceInfo.UserStatus; } } } - Add WorkflowUtils class to the project. Notice that Translate method is loading assembly from Visual Studio PublicAssemblies folder:
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------ using System; using System.Text; using System.Xaml; using System.Xml; using System.Xml.Linq; using Microsoft.Activities.Design.ExpressionTranslation; using Microsoft.Workflow.Client; using System.Reflection; namespace Microsoft.Workflow.Samples.Common { public class WorkflowUtils { public static WorkflowManagementClient CreateForSample(string rootScope, string scopeName) { var rootClient = new WorkflowManagementClient(new Uri(rootScope)); return rootClient.CurrentScope.PublishChildScope(scopeName, new ScopeDescription() { UserComments = string.Format("For {0} sample only", scopeName) }); } public static XElement Translate(string xamlFile) { string translatedWorkflowString = null; Assembly wfAssembly = Assembly.LoadFile(@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.SharePoint.DesignTime.Activities.dll"); XamlXmlReaderSettings settings = new XamlXmlReaderSettings(); settings.LocalAssembly = wfAssembly; using (XamlReader xamlReader = new XamlXmlReader(xamlFile, settings)) { TranslationResults result = ExpressionTranslator.Translate(xamlReader); if (result.Errors.Count == 0) { StringBuilder sb = new StringBuilder(); using (XmlWriter xmlWriter = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true })) { using (XamlXmlWriter writer = new XamlXmlWriter(xmlWriter, result.Output.SchemaContext)) { XamlServices.Transform(result.Output, writer); } } translatedWorkflowString = sb.ToString(); } else { throw new InvalidOperationException("Translation errors"); } } return XElement.Parse(translatedWorkflowString); } public static void PrintDone() { Print("[Done]", ConsoleColor.Green); } public static void Print(string message, ConsoleColor color) { ConsoleColor currentColor = Console.ForegroundColor; Console.ForegroundColor = color; Console.WriteLine(message); Console.ForegroundColor = currentColor; } } } - Now you need to find out the GUID of the module which was used in deploying workflow (prerequisite). This GUID is located in the Module element, Url attribute in Elements.xml file in workflow folder. For example, in Elements.xml file:
<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="Workflow1" Url="wfsvc/86c7e42d4fe14b839d55fcbb6dde7b9c"> <File Url="Workflow.xaml" Type="GhostableInLibrary" Path="Workflow1\Workflow.xaml" DoGUIDFixUp="TRUE"> <Property Name="ContentType" Value="WorkflowServiceDefinition" /> <Property Name="isReusable" Value="true" /> <Property Name="RequiresInitiationForm" Value="False" /> <Property Name="RequiresAssociationForm" Value="False" /> <Property Name="WSPublishState" Value="3" /> <Property Name="WSDisplayName" Value="Workflow1" /> <Property Name="WSDescription" Value="My 'Workflow1' Workflow" /> <!-- If you change the name or Url of your custom initiation or association form, remember to update the corresponding property value (InitiationUrl or AssociationUrl) to match the new web relative url. --> <Property Name="RestrictToType" Value="List" /> <Property Name="RestrictToScope" Value="{$ListId:Shared Documents;}" /> </File> <File Url="WorkflowStartAssociation" Path="Workflow1\WorkflowStartAssociation" Type="GhostableInLibrary"> <Property Name="WSDisplayName" Value="Workflow1 - Workflow Start" /> <Property Name="ContentType" Value="WorkflowServiceSubscription" /> <Property Name="WSPublishState" Value="3" /> <Property Name="WSEventType" Value="WorkflowStart" /> <Property Name="WSEnabled" Value="true" /> <Property Name="WSGUID" Value="19cbf8a6-4af8-462c-b014-c8d7c0e327c1" /> <Property Name="WSEventSourceGUID" Value="{$ListId:Shared Documents;}" /> <Property Name="Microsoft.SharePoint.ActivationProperties.ListId" Value="{$ListId:Shared Documents;}" /> <Property Name="HistoryListId" Value="{$ListId:Lists/WorkflowHistoryList;}" /> <Property Name="TaskListId" Value="{$ListId:Lists/WorkflowTaskList;}" /> </File> </Module> <ListInstance FeatureId="{2c63df2b-ceab-42c6-aeff-b3968162d4b1}" TemplateType="4501" Title="wfsvc" Description="This list instance is used by SharePoint to keep track of workflows. Do not modify." Url="wfsvc" RootWebOnly="FALSE" /> </Elements>
this GUID is 86c7e42d4fe14b839d55fcbb6dde7b9c. Remember this GUID, you will need it in the following step. - Now you need to query workflow resource management database to find out the scope path of your workflow. If you left database name with default value during configuration of workflow farm, this query should get you the scope path (replace the GUID in query with GUID from the previous step):
SELECT [Path]
FROM [WFResourceManagementDB].[dbo].[Scopes] s
join [WFResourceManagementDB].[dbo].[Activities] a on s.ScopeId = a.ScopeId
where a.Name = 'WorkflowXaml_86c7e42d_4fe1_4b83_9d55_fcbb6dde7b9c' - Now it's time to change x:Class attribute in the workflow.xaml file. Last token in the attribute should contain GUID from step 5. For example: x:Class="In2.Ilas.Sp.Ecase.PukWf.WorkflowXaml_ed00d3bd_4796_41ba_b288_35ce2226f89a"
- Finally, console application should have the following code (replace the path from step 6 and workflow name from step 5):
using Microsoft.SharePoint; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.WorkflowServices; using Microsoft.Workflow.Client; using Microsoft.Workflow.Samples.Common; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { WorkflowManagementClient client = new WorkflowManagementClient("http://zg-sp2013-02:12291/SharePoint/default/030e8465-c66c-4f9f-83af-e64d5a4a799b/61aa1fff-103e-49c8-bc56-395c27ca7f81"); client.Activities.Publish(new ActivityDescription(WorkflowUtils.Translate("Workflow.xaml")) { Name = "WorkflowXaml_ed00d3bd_4796_41ba_b288_35ce2226f89a" }); } } } - Copy Workflow.xaml file to console application's folder.
- Run the application.
Complete solution is available for download.
List of types in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.SharePoint.DesignTime.Activities.dll assembly:
namespace Microsoft.SharePoint.DesignTime.Activities
{
[ComVisible(false)]
public class AppOnlySequence : Activity, ISupportInitialize
[ComVisible(false)]
public class AtomicTaskItemUpdatedHelper : Activity, ISupportInitialize
[ComVisible(false)]
public class BuildSPListItemWebLink : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class BuildSPUri : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class Calc : Activity, ISupportInitialize
[ComVisible(false)]
public class CallHTTPWebService : Activity, ISupportInitialize
[ComVisible(false)]
public class CheckInItem : Activity, ISupportInitialize
[ComVisible(false)]
public class CheckOutItem : Activity, ISupportInitialize
[ComVisible(false)]
public class Comment : Activity, ISupportInitialize
[ComVisible(false)]
public class CompositeTask : Activity, ISupportInitialize
[ComVisible(false)]
public class CompositeTaskHelper : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class ConvertPropertiesForSPListItem : Activity, ISupportInitialize
[ComVisible(false)]
public class ConvertTimeZoneFromSPLocalToUtc : Activity<DateTime>, ISupportInitialize
[ComVisible(false)]
public class ConvertTimeZoneFromUtcToSPLocal : Activity<DateTime>, ISupportInitialize
[ComVisible(false)]
public class CopyItem : Activity, ISupportInitialize
[ComVisible(false)]
public class CreatedBy : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class CreatedInRange : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class CreateListItem : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class DateInterval : Activity<double>, ISupportInitialize
[ComVisible(false)]
public class DefaultRetryPolicy : Activity, ISupportInitialize
[ComVisible(false)]
public class DelayFor : Activity, ISupportInitialize
[ComVisible(false)]
public class DelayUntil : Activity, ISupportInitialize
[ComVisible(false)]
public class DeleteListItem : Activity, ISupportInitialize
[ComVisible(false)]
public class Email : Activity, ISupportInitialize
[ComVisible(false)]
public class ExpandGroupToUsers : Activity<Collection<string>>, ISupportInitialize
[ComVisible(false)]
public class ExpandInitFormUsers : Activity<Collection<string>>, ISupportInitialize
[ComVisible(false)]
public class ExtractSubstringFromEnd : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class ExtractSubstringFromIndex : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class ExtractSubstringFromIndexLength : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class ExtractSubstringFromStart : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class GenerateEmailDynamicValue : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class GetCurrentItemGuid : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class GetCurrentItemId : Activity<int>, ISupportInitialize
[ComVisible(false)]
public class GetCurrentListId : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class GetHistoryListId : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class GetItemIdInCache : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class GetTaskListId : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class IsNull : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsSPListItemPropertyLookupToDocsField : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsValidUser : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class JoinChoicesFromSPFieldMultiChoice : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class JoinIdOrValueFromSPFieldLookupMulti : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class JoinSiteUserInfoListPropertyFromSPFieldUserMulti : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class JoinSPPrincipalPropertyFromInitFormParamUserMulti : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupSPChoiceFieldIndex : Activity<int>, ISupportInitialize
[ComVisible(false)]
public class LookupSPField : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPFields : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPGroup : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPGroupMembers : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPList : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItem : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemBooleanProperty : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemDateTimeProperty : Activity<DateTime>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemDoubleProperty : Activity<double>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemDynamicValueProperty : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemGuid : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemId : Activity<int>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemInt32Property : Activity<int>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemProperty : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemPropertyNameInREST : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemSPFieldLookupMultiProperty : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemSPFieldLookupProperty : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListItemStringProperty : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupSPListProperty : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPPrincipal : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPPrincipalId : Activity<int>, ISupportInitialize
[ComVisible(false)]
public class LookupSPPrincipalProperty : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupSPTaskAssignedToDisplayName : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupSPTaskListItemAssignedTo : Activity<Collection<string>>, ISupportInitialize
[ComVisible(false)]
public class LookupSPUser : Activity<DynamicValue>, ISupportInitialize
[ComVisible(false)]
public class LookupSPUserProperty : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LookupWorkflowContextProperty : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class LoopNTimes : Activity, ISupportInitialize
[ComVisible(false)]
public class ModifiedBy : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class ModifiedInRange : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class RegisterForSharePointEvent : Activity, ISupportInitialize
[ComVisible(false)]
public class ReplaceEmailTokens : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class RetryForDurationPolicy : Activity, ISupportInitialize
[ComVisible(false)]
public class SetField : Activity, ISupportInitialize
[ComVisible(false)]
public class SetItemIdInCache : Activity, ISupportInitialize
[ComVisible(false)]
public class SetRelatedItem : Activity, ISupportInitialize
[ComVisible(false)]
public class SetTimeField : Activity<DateTime>, ISupportInitialize
[ComVisible(false)]
public class SetWorkflowStatus : Activity, ISupportInitialize
[ComVisible(false)]
public class SingleTask : Activity, ISupportInitialize
[ComVisible(false)]
public class TranslateDocument : Activity, ISupportInitialize
[ComVisible(false)]
public class UndoCheckOutItem : Activity, ISupportInitialize
[ComVisible(false)]
public class UpdateListItem : Activity, ISupportInitialize
[ComVisible(false)]
public class WaitForCustomEvent : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class WaitForFieldChange : Activity, ISupportInitialize
[ComVisible(false)]
public class WaitForItemEvent : Activity, ISupportInitialize
[ComVisible(false)]
public class WebUri : Activity<string>, ISupportInitialize
[ComVisible(false)]
public class WordsInTitle : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class WorkflowInterop : Activity<Guid>, ISupportInitialize
[ComVisible(false)]
public class WriteToHistory : Activity, ISupportInitialize
}
namespace Microsoft.SharePoint.DesignTime.Activities.Expressions
{
[ComVisible(false)]
public class ContainsStringIgnoreCase : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsEqualDate : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsEqualDateTime : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsEqualDynamicValue : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsEqualStringIgnoreCase : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsEqualUser : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsGreaterThanDateTime : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsGreaterThanOrEqualDateTime : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsLessThanDateTime : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class IsLessThanOrEqualDateTime : Activity<bool>, ISupportInitialize
[ComVisible(false)]
public class MatchesString : Activity<bool>, ISupportInitialize
}
namespace XamlStaticHelperNamespace
{
[GeneratedCode("XamlBuildTask", "4.0.0.0")]
internal class _XamlStaticHelper
}
2015-08-19
Failed to load receiver assembly, System.IO.FileNotFoundException: Could not load file or assembly or one of its dependencies on Feature Receiver in SharePoint 2013
After breaking the deploy process by pressing CTRL+BREAK during Visual Studio 2012 deploy of SharePoint 2013 WSP I wasn't able to deploy my package any more. Deploy was failing with the message:
Failed to load receiver assembly...
After fiddling with Process Monitor and Fusion Log for a while I couldn't pinpoint why assembly couldn't be loaded. Assembly exists at appropriate location in GAC but my concern is that Visual Studio tries to access it few seconds before it is actually copied to GAC during deploy process. Aforementioned exception happens during feature activation phase of deploy process.
My solution to the problem was to change assembly version from 1.0.0.0 to 1.0.0.1 and build the SharePoint project. After that I I deleted feature receiver and added feature receiver again so that feature manifest XML file gets updated with correct version of feature receiver assembly.
Failed to load receiver assembly...
After fiddling with Process Monitor and Fusion Log for a while I couldn't pinpoint why assembly couldn't be loaded. Assembly exists at appropriate location in GAC but my concern is that Visual Studio tries to access it few seconds before it is actually copied to GAC during deploy process. Aforementioned exception happens during feature activation phase of deploy process.
My solution to the problem was to change assembly version from 1.0.0.0 to 1.0.0.1 and build the SharePoint project. After that I I deleted feature receiver and added feature receiver again so that feature manifest XML file gets updated with correct version of feature receiver assembly.
2014-10-29
Visual Studio 2013 Cannot Deploy Content Type Updates
After spending 10+ hours trying to figure out why content types included in my wsp cannot be deployed using Visual Studio 2013 deploy without recreating SP site I must say I am disappointed with my findings. Content types cannot be removed from SP site by using Visual Studio 2013 Retract command. My colleague can successfully deploy (and retract) content types using Visual Studio 2012, so I decided to look inside what is really happening under the hood.
Apparently, both Visual Studio versions, 2012 and 2013, are using Microsoft.VisualStudio.SharePoint.Commands.Implementation.V5.dll to deploy and retract SharePoint solutions to SharePoint sites. But the big difference between the two is that VS 2012 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures in a way so that it calls SPFeatureCollection.Remove method with force argument set to true which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 2. When this parameter is set to 2 then stored procedure skips a call to another stored procedure named proc_IsContentTypeInUse. This basically forces the deletion of content type.
VS 2013 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures with a call to Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeature method which makes a call to SPFeatureCollection.Remove with force argument set to false which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 1. This prevents content type from being deleted.
I am using version of VS 2013 which is Visual Studio Premium 2013 Version 12.0.30723.00 Update 3.
I hope MS provides a fix to this issue soon. Until then I am reverting to VS 2012.
Apparently, both Visual Studio versions, 2012 and 2013, are using Microsoft.VisualStudio.SharePoint.Commands.Implementation.V5.dll to deploy and retract SharePoint solutions to SharePoint sites. But the big difference between the two is that VS 2012 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures in a way so that it calls SPFeatureCollection.Remove method with force argument set to true which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 2. When this parameter is set to 2 then stored procedure skips a call to another stored procedure named proc_IsContentTypeInUse. This basically forces the deletion of content type.
VS 2013 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures with a call to Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeature method which makes a call to SPFeatureCollection.Remove with force argument set to false which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 1. This prevents content type from being deleted.
I am using version of VS 2013 which is Visual Studio Premium 2013 Version 12.0.30723.00 Update 3.
I hope MS provides a fix to this issue soon. Until then I am reverting to VS 2012.
2014-09-22
ECB Missing on Manage User Profiles page in Central Administration
Today I was working on SharePoint 2013 dev machine when I was trying to sync AD accounts with SharePoint. I wanted to set emails for accounts to test workflow tasks but I was surprised I couldn't edit user profiles because ECB menus were not rendered on Manage User Profiles (ProfMngr.aspx) page:
Apparently the problem lies in the fact that CA site was browsed with IE 11. To fix this problem, site has to be added to compatibility view list. In Internet Explorer 11 open Tools menu and choose Compatibility View Settings menu item while browsing CA site. The following window should open:
Click the Add button. Window should now look like this:
Close the window and voila, now ECB should be rendered. Notice how grid lines are added to the list:
2014-08-26
Error occurred in deployment step ‘Activate Features': System.TimeoutException: The HTTP request has timed out after 20000 milliseconds.
I am running SP 2013 dev environment and I recently ran into a problem described in the post title. I tried to deploy a solution with feature activation which included SP 2013 Workflow SPIs. I tried to solve the issue by applying a solution described here but it wasn't helpful in my situation. I already had registry settings set up to extend timeout period for SharePoint deployment.
Visual studio output window might look like this:
Activating feature 'Feature1' ...
Error occurred in deployment step 'Activate Features': System.TimeoutException: The HTTP request has timed out after 20000 milliseconds. ---> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.OnGotResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.Workflow.Client.Ht
I noticed that I had Fiddler2 running in the background while trying to deploy my solution. I exited Fiddler2 application and tried to deploy again. This time deploy was successful. It very well might be a cause of error. Just to be sure I tried to reproduce the same behavior again by starting Fiddler2 again and trying to deploy the wsp using Visual Studio 2012. This time VS couldn't delete workflows and workflow associations from the site but it was able to deploy successfully. I turned off Fiddler2 again and tried to deploy, and it went smooth, without any errors. I might be wrong but it seems to me that Fiddler's proxy is interfering with deployment of workflows.
I know there are many reasons causing this error but this solution helped me. Hopefully it helps someone else.
Visual studio output window might look like this:
Activating feature 'Feature1' ...
Error occurred in deployment step 'Activate Features': System.TimeoutException: The HTTP request has timed out after 20000 milliseconds. ---> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.OnGotResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.Workflow.Client.Ht
I noticed that I had Fiddler2 running in the background while trying to deploy my solution. I exited Fiddler2 application and tried to deploy again. This time deploy was successful. It very well might be a cause of error. Just to be sure I tried to reproduce the same behavior again by starting Fiddler2 again and trying to deploy the wsp using Visual Studio 2012. This time VS couldn't delete workflows and workflow associations from the site but it was able to deploy successfully. I turned off Fiddler2 again and tried to deploy, and it went smooth, without any errors. I might be wrong but it seems to me that Fiddler's proxy is interfering with deployment of workflows.
I know there are many reasons causing this error but this solution helped me. Hopefully it helps someone else.
2014-08-20
Implementation of ribbon button availability by calling asynchronous methods
It is known that SharePoint ribbon can be extended by implementing CustomAction Ribbon.Library.Actions.AddAButton. SharePoint allows you to dynamically control whether this ribbon button should be enabled. This is done by implementing Javascript logic in CommandUIHandler's EnabledScript attribute.
The problem is if you want to include asynchronous call in aforementioned attribute because this Javascript block must return boolean value. So, when SharePoint calls asynchronous method it will not get the result immediately. Instead, it will get the result of async call in callback function but it's too late, Javascript block has already returned.
The solution to this problem was very well described by Andrew Connell on his blog post. Since no code snippets were included in this post I decided to provide it here because there is one caveat that is not so obvious from first look at the Andrew's post.
This is the implementation of ribbon button in Elements.xml:
This makes it easier to debug the solution if Javascript code is included in external file. Prerequisite for this step is to add new Javascript file to layouts mapped folder.
Next piece of code is the actual implementation of enabling/disabling the button based on current user's group membership in SPRibbonHelperScript.js:
The problem is if you want to include asynchronous call in aforementioned attribute because this Javascript block must return boolean value. So, when SharePoint calls asynchronous method it will not get the result immediately. Instead, it will get the result of async call in callback function but it's too late, Javascript block has already returned.
The solution to this problem was very well described by Andrew Connell on his blog post. Since no code snippets were included in this post I decided to provide it here because there is one caveat that is not so obvious from first look at the Andrew's post.
This is the implementation of ribbon button in Elements.xml:
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Library.Share.Controls._children">
<Button Id="Ribbon.Library.Share.NewRibbonButton"
Command="NewRibbonButtonCommand"
Image16by16="/_layouts/15/Style/buttonIcon16.png"
Image32by32="/_layouts/15/Style/buttonIcon32.png"
LabelText="New case"
ToolTipTitle="Get new case."
ToolTipDescription="Assigns new case to you."
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="NewRibbonButtonCommand"
EnabledScript="javascript:IsCurrentUserMemberOfGroup('puk ref');
"/>
</CommandUIHandlers>
</CommandUIExtension>
Since our project doesn't include customized forms nor master pages we had to include external Javascript file to Elements.xml:
<CustomAction ScriptSrc="/_layouts/15/Scripts/SPRibbonHelperScript.js" Location="ScriptLink" Sequence="1001">
</CustomAction>
This makes it easier to debug the solution if Javascript code is included in external file. Prerequisite for this step is to add new Javascript file to layouts mapped folder.
Next piece of code is the actual implementation of enabling/disabling the button based on current user's group membership in SPRibbonHelperScript.js:
var isMemberOfGroup = false;
function IsCurrentUserMemberOfGroup(groupName) {
var currentContext = new SP.ClientContext.get_current();
var currentWeb = currentContext.get_web();
var currentUser = currentContext.get_web().get_currentUser();
currentContext.load(currentUser);
var allGroups = currentWeb.get_siteGroups();
currentContext.load(allGroups);
var group = allGroups.getByName(groupName);
currentContext.load(group);
var groupUsers = group.get_users();
currentContext.load(groupUsers);
currentContext.executeQueryAsync(OnSuccess, OnFailure);
function OnSuccess(sender, args) {
var userInGroup = false;
var groupUserEnumerator = groupUsers.getEnumerator();
while (groupUserEnumerator.moveNext()) {
var groupUser = groupUserEnumerator.get_current();
if (groupUser.get_id() == currentUser.get_id()) {
userInGroup = true;
break;
}
}
if (isMemberOfGroup == false || isMemberOfGroup == 'undefined') {
if (userInGroup == true) {
isMemberOfGroup = userInGroup;
RefreshCommandUI();
}
}
}
function OnFailure(sender, args) {
}
return isMemberOfGroup;
}
Subscribe to:
Posts (Atom)






