CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: SP1

First look at Yammer integration in SharePoint 2013 SP1

I have installed SharePoint SP1 on my development machine. Yammer and OneDrive links have appeared in the Central Administration:

yammer-001

If you go ahead and click “Configure Yammer”, you can activate it:

yammer-002

Because:

Yammer is Microsoft’s recommended tool for social collaboration.

When you activate Yammer, you’ll get this dialog, and the Yammer link in the SuiteBar:

yammer-003

yammer-004

What happens when you click on Yammer, is that you are redirected to Yammer.com and you are prompted a login page.

Then you have a usual yammer site with all your networks and stuff (in my case, SPC14 network):

yammer-005

Then, if you go to your newsfeed, the following message is shown:

yammer-006

This page displays updates for sites you’re following. To connect with people, use Yammer.

There are still many questions about the Yammer and Newsfeed. But I like the activation process in the SharePoint 2013 SP1

Retention policies

Ziegler provides a cool intro, implementation sample and much more.

When deployed we can apply this policy to a contenttype in the UI, or in code.

To create our own expiration logic we have to implement IExpirationFormula and its ComputeExpireDate:

public class TaskExpiration : IExpirationFormula
{
	public DateTime? ComputeExpireDate(SPListItem item,
						XmlNode parametersData)
	{
		if (!item["Status"].Equals("Completed"))
		{
			return null;
		}
		var dt = (DateTime) item["Modified"];
		return dt.AddDays(30);
	}
}

In order to see IExpirationFormula, add a reference to Microsoft.Office.Policy (and maybe Microsoft.Office.DocumentManagement):

To see our custom retention policy, we have to register it in xml, we can do it in Feature Receiver like Yaroslav:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    const string xmlManifest =
       "<PolicyResource xmlns='urn:schemas-microsoft-com:office:server:policy'" +
       " id = 'Takana.TaskRetentionPolicy'" +
       " featureId='Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration'" +
       " type = 'DateCalculator'>" +
       " <Name>Takana Task Retention Policy</Name>" +
       "<Description>Tasks expire 30 days after they have been completed</Description>" +
       "<AssemblyName>Takana.SharePoint, Version=1.0.0.0, Culture=neutral, " +
       "PublicKeyToken=920c0327f8b01d97</AssemblyName>" +
       "<ClassName>Takana.SharePoint.Policies.TaskExpiration</ClassName>" +
       "</PolicyResource>";
    PolicyResourceCollection.Add(xmlManifest);
}

The feature has to be Webapplication scoped, otherwise you get “No access” (“Ingen tillgang” i nb-NO) when you try to add this xmlManifest.

Or in Powershell, like it is described by Microsoft. Create an xml like this:

<PolicyResource xmlns="urn:schemas-microsoft-com:office:server:policy" 
    id = "Takana.TaskRetentionPolicy" 
    featureId="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration" 
    type = "DateCalculator">
    <Name>Takana Task Retention Policy</Name>
    <Description>Tasks expire 30 days after they have been completed</Description>
    <AssemblyName>Takana.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=920c0327f8b01d97</AssemblyName>
    <ClassName>Takana.SharePoint.Policies.TaskExpiration</ClassName>
</PolicyResource>

Then access the xml file and add it to policy resource collection:

$policyResource = Get-Content .\takan.taskretentionpolicy.xml
[Microsoft.Office.RecordsManagement.InformationPolicy.PolicyResource]::ValidateManifest($policyResource)
[Microsoft.Office.RecordsManagement.InformationPolicy.PolicyResourceCollection]::Add($policyResource)

If you want to remove your policy resource, just run delete with your resource id:

[Microsoft.Office.RecordsManagement.InformationPolicy.PolicyResourceCollection]::Delete("Takana.TaskRetentionPolicy")

The items are collected by the “Expiration policy” timer job:

Expiration Policy
Enumerates list items and looks for those with an expiration date that has already occurred. For those items, runs disposition processing. Disposition processing most often results in deleting items, but it can perform other actions, such as processing disposition workflows.

If you want to see the changes directly when developing, you can change the interval of timer job.

Expiration Policy timer job and SP1

If the timer job doesn’t run, re-activate RecordsManagement feature:

Install-SPFeature RecordsManagement -force
stsadm -o setpolicyschedule -schedule "daily at 00:10:00"

This solved the problem why the items are not deleted. But my custom policy resource had to be re-published, too.

Expiration Policy is the timer job which removes the items. What does the Information Management Policy timer job?

To associate a policy to a content type is easy in UI, but not so straight forward in code. Here is some beginning:

$web = get-spweb http://takana
$list = $web.Lists["Tasks"]
$ctype = $list.ContentTypes["Task"]
[Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::CanHavePolicy($ctype)
[Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::CreatePolicy($ctype, $null)
$p = [Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::GetPolicy($c)
$data = Get-Content .\takana.taskretentionpolicy.schedule.xml
$p.Items.Add("Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration", $data)
$site = get-spsite http://dev
[Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::ProcessChanges($site)

This code loads the xml from the same folder:

<Schedules nextStageId="2">
    <Schedule type="Default">
        <stages>
            <data stageId="1" stageDeleted="true" />
                <formula id="Takana.TaskRetentionPolicy" />" +
                <action type="action" id="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Action.Delete" />
            </data>
        </stages>
    </Schedule>
</Schedules>

Or add to a list:

$web = get-spweb http://takana
$list = $web.Lists["Tasks"]
$policySettings = new-object Microsoft.Office.RecordsManagement.InformationPolicy.ListPolicySettings($list)

if ($policySettings.ListHasPolicy -neq $false)
{
	#make the list use a custom list policy
	$policySettings.UseListPolicy = true;
	$policySettings.Update();
}

The code to add policy to a c ontent type has not been tested yet.

Update 20120831: A nice description and code samples on Yaroslav Pentsarsky’s blog: Help users manage SharePoint content by setting expiration policies with PowerShell

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know and share about...

SharePointDiver

SharePoint på ren svenska