Part 2
Step 4 - Create a custom workflow
For More details on WSS workflow check this article .
Open the Sequential Workflow file (PublishingWorkflow.cs) in design mode and add following activites -
- OnWorkFlowActivated activity
- Sequence activity : Rename this activity as 'PendingNotfications' and add following child activites -
- SendEmail - Rename this activity as 'SendRequestForApproval'
- SendEmail - Rename this activity as 'SendPendingNoticeToPublisher'
- While activity – Rename this activity as 'WhileWaitingForApproval' and add following child activities.
- OnWorkflowItemChanged activity
- IfElse activity
- First branch : Add following child activities -
- InvokeWebService activity – Rename this activity as 'EPMProjects'.Add the web reference as -
Reference name – psiProjects ,
URL = http://server/pwa/_vti_bin/psi/project.asmx - SendEmail activities - Rename this activity as 'SendApprovalEmail'
- InvokeWebService activity – Rename this activity as 'EPMProjects'.Add the web reference as -
- Second Branch : Add following child activities -
- SendEmail activities - Rename this activity as 'SendRejectedEmail'
- First branch : Add following child activities -
The final design view should look like this -
The red exclamation icon in the upper-right corner of activities icon indicates that a required property must be set.Clicking the icon displays the list.
Now open the PublishingWorkflow.cs file in code view and add following using statement & class members -
- using EPMWF.psiProjects; //NameSpace.Psi Web Refrence Name
- public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
Set Activity Properties
Open the workflow file in design view and set the required properties of each activity as mentioned below -
- Activity - OnWorkFlowActivated1
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow
WorkflowProperties\Name = PublishingWorkflow
WorkflowProperties\Path = workflowProperties - Invoked = OnWorkflowActivated1_Invoked
After You Enter method name here, VS.net will jump to code with a method signature created.
- Correlation Token = publishWorkflowToken
- Activity = SendRequestForApproval
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow - Body - select the Body row and click the ellipsis.Click Bind a New member field.enter name = m_MailToBody ; Select Create field option, click Ok .Verify Name and Path
Body\Name = PublishingWorkflow
Body\Path = m_MailToBody - Headers - Create field in the same as done for Body.Name =m_MailToHeader.The Headers property is a hash where the Subject and To fields can be specified
Headers\Name = PublishingWorkflow
Headers\Path = m_MailToHeader - MethodInvoking = SendRequestsForApproval_Invoking
After You Enter method name here, VS.net will jump to code with a method signature created.
- Correlation Token = publishWorkflowToken
- Activity = SendPendingNoticeToPublisher
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow
Body\Name = PublishingWorkflow
Body\Path = m_MailToBody
Headers\Name = PublishingWorkflow
Headers\Path = = m_MailToHeader
MethodInvoking = SendPendingApproval_Invoking
- Correlation Token = publishWorkflowToken
- Activity = WhileWaitingForApproval
- Condition = Code Condition
- Condition = WhileWaitingForApproval_ Condition
After You Enter method name here, VS.net will jump to code with a method signature created.
- Activity = OnWorkflowItemChanged
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow
- Correlation Token = publishWorkflowToken
- Activity = ifElseBranchActivity1
- Condition =Code Condition
Condition = IfApproved_Condition
- Condition =Code Condition
- Activity = EPMProjects
- MethodName =QueuePublish
- Create fields for following properties in the same way as in Body
ReturnValue = m_PublishResult
JobUid = m_PublishJobGuid
ProjectUid = m_ProjectGuid
WssUrl = m_PublishWssUrl - FullPublish=True
- Invoking =PsiQueuePublish_Invoking
VS.net will jump to code with a method signature created.
- Activity = SendApprovalEmail
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow
Body\Name = PublishingWorkflow
Body\Path = m_MailToBody
Headers\Name = PublishingWorkflow
Headers\Path = = m_MailToHeader
MethodInvoking = SendApproval_Invoking
- Correlation Token = publishWorkflowToken
- Activity = SendRejectedEmail
- Correlation Token = publishWorkflowToken
Correlation Token\OwnerActivityName = PublishingWorkflow
Body\Name = PublishingWorkflow
Body\Path = m_MailToBody
Headers\Name = PublishingWorkflow
Headers\Path = = m_MailToHeader
MethodInvoking = SendRejected_Invoking
- Correlation Token = publishWorkflowToken
After setting all these properties Visual studio will automatically create some member declaration & empty method signatures for you. The code file will look like this...
namespace EPMWF
{
public sealed partial class PublishingWorkflow: Microsoft.SharePoint.WorkflowActions.SharePointSequentialWorkflowActivity
{
public PublishingWorkflow()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
public String m_MailToBody = default(System.String);
public System.Collections.Specialized.StringDictionary m_MailToHeader = new System.Collections.Specialized.StringDictionary();
private void OnWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e){}
private void SendRequestsForApproval_Invoking(object sender, EventArgs e){}
private void SendPendingApproval_Invoking(object sender, EventArgs e){}
private void WhileWaitingForApproval_Condition(object sender, ConditionalEventArgs e)
{}
private void IfApproved_Condition(object sender, ConditionalEventArgs e){}
public Guid m_ProjectGuid = default(System.Guid);
public ProjectRelationsDataSet m_PublishResult = new EPMWF.psiProjects.ProjectRelationsDataSet();
public Guid m_PublishJobGuid = default(System.Guid);
public String m_PublishWssUrl = default(System.String);
private void PsiQueuePublish_Invoking(object sender, InvokeWebServiceEventArgs e){}
private void SendRejected_Invoking(object sender, EventArgs e){}
private void SendApproval_Invoking(object sender, EventArgs e){}
}
}
Part 4 - Writing Codes for Activities
No comments:
Post a Comment