How to get data from workflow association form

Hey Guys,

I’ve client requirement, in which I need to develop custom Workflow. Also need to display group names on Initiation form which has been entered in to Association form. So here I am going to share code snippets to get data from Association form and display in to Initiation Form.

Note: Both forms are ASPX pages.

To achieve this, need to write below code in Initiation Form load event.

string assignedGroups = string.Empty;

//open current web

SPWeb site = SPContext.Current.Web;

//get the list object

SPList lstdemo = site.Lists[“ListName”];

//get instance of workflow association

SPWorkflowAssociationCollection AssociationWFCollection = lstdemo.WorkflowAssociations;

if (AssociationWFCollection != null)

{

foreach (SPWorkflowAssociation wfassociation in AssociationWFCollection)

{

//assign workflow association data to the variable

assignedGroups = wfassociation.AssociationData;

}

}

That’s it. This was you can get data from AssociationForm to InitiationForm.

No comments: