If you are creating a SharePoint Workflow with a Delay Activity in Visual Studio, and want to be able to change the delay timeout through a configuration file—for example: to have a short delay for testing and a longer delay in production without having to recompile your code—then this setup is actually quite simple.
I’ve decided to write this short post because, although this is really the same as reading a config entry from any other .NET based program, SharePoint workflows can be a little intimidating and make you think that things aren’t as simple as they are in, say for example, a straight ASP.NET web forms app.
However, it really is this simple:
- Add an AppSettings entry to the web.config in your Virtual Directory location (i.e. C:\inetpub\wwwroot\wss\VirtualDirectories\MySharePointSite\web.config) something like this:
<add key=”WorkflowDelayTimeoutDuration” value=”00:05:00″/>
- Read the app setting value from the code behind of your workflow for the delay activity in the Invoked event handler (notice I put a default value in the else block) :
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
workflowId = workflowProperties.WorkflowId;
if (ConfigurationManager.AppSettings["WorkflowDelayTimeoutDuration"] != null)
delayActivity1.TimeoutDuration = TimeSpan.Parse(ConfigurationManager.AppSettings["WorkflowDelayTimeoutDuration"]);
delayActivity1.TimeoutDuration = new TimeSpan(1, 0, 0);
- For your reference, here is what my Properties window looks like in this scenario:
Posted by Jason Graham on June 19, 2013
Ok, after a frustrating while of trying to figure out an easy way to get the FULL (Absolute) URL for a ListItem’s parent web using the SharePoint Client Object Model I discovered one thing for sure: There are an abundance of ways to easily find the ServerRelativeUrl for many objects in the Client OM, but that is not what I needed.
After talking to a co-worker, we finally found an easy way to get the parent web’s absolute URL when dealing with at Client OM ListItem. The key is looking at the Context.
Assuming that you have a variable called “item” that represents an SP Client OM ListItem, you can get the full URL for the parent web like this:
string parentWebAbsUrl = item.ParentList.ParentWeb.Context.Url;
Sometimes it’s the simple things that get you. Hope that helps you save some time! Thanks for reading.
Posted by Jason Graham on March 30, 2012
If you would like to programmatically determine a List Type in C# using the SharePoint Client Object Model, then all you need to do is compare the list’s BaseTemplate, which is an integer identifier, to one of the ListTemplateType enumeration values—casting it to an int as seen below:
bool isDocumentLibrary ;
using (ClientContext clientContext = new ClientContext(baseSiteUrl))
Web web = clientContext.Web;
List list = clientContext.Web.Lists.GetByTitle(listName);
if (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary)
isDocumentLibrary = true;
That’s all there is to it. Now you can take this and modify it in any way that you need to make list type determination more dynamic, if you aren’t just needing to compare to a single ListTemplateType as shown above.
Posted by Jason Graham on March 26, 2012