vrijdag 6 juli 2012

SP2010 Sequential Workflow Send Email

Send Email in a sequential workflow


Create a Send Email task activity on your workflow.

Don't forget to set the CorrelationToken to the same token as your workflow! See earlier post. 

The code behind of that task is:

SPUser siteOwner = IntranetUtility.GetSPUser(currentItem, IntranetFieldId.SiteRequest.SiteOwner);
SPUser siteBackupOwner = IntranetUtility.GetSPUser(currentItem, IntranetFieldId.SiteRequest.SiteBackupOwner);

SendEmail confirmationMail = (SendEmail)sender;
confirmationMail.To = siteOwner.Email + ";" + siteBackupOwner.Email;
confirmationMail.Subject = string.Format("Your site {0} is created", currentItem.Title);
confirmationMail.Body = "Link to created site";
 
SPUtility.SendEmail(workflowProperties.Web, true, false, confirmationMail.To, confirmationMail.Subject, confirmationMail.Body);

SP2010: Sequential Workflow Correlation Token SendEmail

Workflow Foundation Correlation Token error

Within a workflow that I was developing, there was a requirement to notify a group of SharePoint users that a lookup service had failed. This particular activity was within a parallel activity sequence. I chose to use the SendEmail activity to notify the users, but incorrectly set the Correlation Token to a new value. When testing this functionality in the workflow I received an error:

SharePoint LOG
  1. WinWF Internal Error, terminating workflow Id#
  2. System.InvalidOperationException: Correlation value has not been initialized on declaration emailToken_JobNumberCreate for activity sendEmail_JobNumberNotCreated. at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken

The correct Correlation Token for a SendMail Activity is the “Workflow” token. The reason, which is fairly obvious, is that the SendEmail activity maps to the workflow, not to a task, which would require a Task Token

vrijdag 22 juni 2012

SharePoint 2010: Manage navigation programmatically C#

How to set navigation options programmatically?

  • Don't inherit global navigation
  • Don't include pages in global navigation
  • Include subsites in quicklaunch
  • Set ordering
  • Set navigation items of the topnavigation manually via xml
  • Add parent site to the quicklaunch if it exist

donderdag 14 juni 2012

SharePoint 2010: Create a custom wiki page

How to create a custom wiki page in SharePoint 2010 with a simple FeatureReceiver?


With this code it's pretty easy:

private string wikiFullContent = string.Empty;

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
//* Define page payout
wikiFullContent = FormatBasicWikiLayout();
//* Add page to library
SPList sitePages = web.Lists.TryGetList("$Resources:core,WikiLibDefaultTitle;");
if (sitePages == null)
{
sitePages = web.Lists.EnsureSitePagesLibrary();
}


woensdag 13 juni 2012

SharePoint 2010: Restrict web templates

Define which web templates may be available when you create a subsite


In the analysis of a new project was described that the users only a few webtemplates could see when they want to create a new subsite. After some research on the internet I found that it is possible to define that via the UI of SharePoint 2010:

Site Actions -> Site Settings -> Page layouts and site templates

(default)

(after the selection)



In this settings page you can define which web templates you set available but that's not a solution on the question of the analysis. You can't ask to each contributor to set this setting by themself so I wrote a featureReceiver and via featureStapling I hang to the defined site templates.
Important! If you want to do this via code be sure that the Publishing Infrastructure and Publshing Feature is activated!

dinsdag 12 juni 2012

SharePoint 2010: Starter v4.master without tables

Starter v4.master with div tags instead of table tags

Standard is the default masterpage of SharePoint (v4.master) build on tables. Every designer knows that tables only bring troubles so I desided to convert all the tables to div tags.

Via the link below you can download the result.


Enjoy it!

SharePoint 2010: Show the parent site in the breadcrumb

How to show the parent site in the breadcrumb of your custom masterpage?

By default there is a masterpage that has this configuration. You can find this in the default nightandday.master.

What needs to be done to have this in your custom masterpage?

Add following code to in the <div class="s4-ca"> tag:

<!-- Breadcrumb with parent site -->
<div class="breadcrumb">
  <asp:SiteMapPath
   runat="server"
   SiteMapProviders="SPSiteMapProvider,SPXmlContentMapProvider"
   RenderCurrentNodeAsLink="false"
   NodeStyle-CssClass="breadcrumbNode"
   CurrentNodeStyle-CssClass="breadcrumbCurrentNode"
   RootNodeStyle-CssClass="breadcrumbRootNode"
   HideInteriorRootNodes="true"
   SkipLinkText="" />
</div>

The css here defined contains the default style of the v4.master headbreadcrumb.