Showing posts with label workflow. Show all posts
Showing posts with label workflow. Show all posts

Sunday, June 22, 2014

Cancel Workflow Instances using powershell script

Hi All,

Recently, I worked on the requirement to terminate the running workflow instances associtated to the specific list using powershell script.

I used WorkflowManager and then Cancel method with passiing the workflow instance class,

Here  I terminated the workflows for which the workflow status is running.

here is the script.

 
#Site URL
$siteurl=Read-Host "Enter Site URL"
$web = Get-SPWeb $siteurl
$web.AllowUnsafeUpdates = $true;    

#List Name
$listname=Read-Host "Enter list Name"
$list = $web.Lists["$listname"];

if($list -ne $null)
{
# Iterate through all Items in List and all Workflows on Items.         
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {

#Cancel Workflows      

if($wf.InternalState - eq 'Running')
{  
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);      
}
}
}
$web.Dispose();
}
else
{
 write-host "List does not exist"
}

Specific feature Activated sites report using Powershell

Hi All,

when you got the requirement to know the list of site collections where a specific feature got activated at the site collection level, the below script will be helpful.

For example, to know the list of site collection where the Nintex wokrflow got activated, use the below script.

 
$GC = Start-SPAssignment

$sites=$GC | Get-SPSite -Limit All


foreach($site in $sites)

{

$feature=Get-SPFeature -Site $site | Where-object {$_.DisplayName -eq "NintexWorkflow"}

if($feature -ne $null)
{
  write-host "Feature activated at site" $site.Url

}
$site.dispose()
}

Stop-SPAssignment $GC
 
If you want the spcific publishing feature or custom feature activated site collection list, replace the feature display name with the custom one.
 
 

Sunday, August 26, 2012

SharePoint 2010 OOB approval workflow customization


Hi Guys,

Recently I worked on a requirement to customize the OOB approval workflow in sharepoint designer.

The customer is looking for the  email customization at each stage of the approver  and the workflow initiator.

For e.g., if there are two approvers sequentially and if the approver approves the task, then second approver should know that the document was initially approved by first approver and waiting for the current approval from him self and similar notification to workflow initiator so that the initiator can contact drectly the pending approver to get task immediately.

Below are the steps, I implemented in SharePoint Designer   for acheivimg this customization.

Go to SP designer and open the workflows section of the site.

Select Approval workflow and do right clcik and then do copy and modify option.

After that paste the work flow and change the title and desctiption as required.

Once it it ready, click on Edit Workflow link and then click on the associate workflow part.

image comes here

Here you find 4 links to modify the task options like "Change the behaviour of the single task" , "Change the behaviour of overall task process" etc.

Click on "Change the behaviour of single task" and then do check for the different conditions about the task.

Go to the condition "if task Extenal participant is empty". there is already existing notiffication email action available, Do modify that with your content.

image comes here.

You can address approver  dsiplay name, document link can be embedded here, "Open this task"  link can be added inside the mail body.

image comes here.

Similary if you want notify the initiator about the task approvers, add the similar email action below this and customize the email body accordingly.

image comes here.

Once the approver do the approval/rejection, he can be notified through mail saying that the document is approved/rejected.

This can be done with adding email condition in the below way.

image comes here.