Showing posts from December, 2013

Custom action to a callout in SharePoint 2013

During my POC, I was trying to add custom action to a callout same like, Share and follow. found easy way to do it with following script. SP.SOD.executeFunc("callout.js", "Callout", function () { var itemCtx = {}; itemCtx.Templates = {}; itemCtx.BaseViewID = 'Callout'; // Define the list template type itemCtx.ListTemplateType = 101; itemCtx.Templates.Footer = function (itemCtx) { return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true); }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx); }); function AddCustomAction (renderCtx, calloutActionMenu) { // Add custom action calloutActionMenu.addAction (new CalloutAction ({ text: "Custom Action", tooltip: 'This is your custom action', onClickCallback: function() { console.log('Alert from custom action'); } })); } We are good to go!!

PowerShell to Cancel All SharePoint Workflows in Progress

I was struck with requirement were having big list and workflow attached to it, need to cancel all running workflows.  It could be either manually traverse all the way and stop it, was next to impossible. Following script helped me to save my time! $web = Get-SPWeb ""; $web.AllowUnsafeUpdates = $true; $list = $web.Lists["CustomListName"]; $count = 0 foreach ($listItem in $list.Items) { foreach ($workflow in $listItem.Workflows) { if(($listItem.Workflows | where {$_.InternalState -ne "Completed"}) -ne $null) { #Cancel Workflows [Microsoft.SharePoint.Workflow.SPWorkflowManager]:: CancelWorkflow($workflow); write-output "Workflow cancelled for : " $listItem.Title; } } } $web.Dispose(); Hope this will save your time!