This project is read-only.

How can I obtain task related informations?

Jun 24, 2009 at 5:32 PM
Is often useful to have access to some task related informations while processing a task form (or usercontrol) 
following code is a cut&paste from TPG Book "... Inside sharepoint..." 
        ListId = Request.QueryString("List")
        TaskList = Web.Lists(New Guid(ListId))
        TaskItem = TaskList.GetItemById(Convert.ToInt32(Request.Params("ID")))
        WorkflowInstanceId = New Guid(DirectCast(TaskItem("WorkflowInstanceID"), String))
        WorkflowInstance = New SPWorkflow(Web, WorkflowInstanceId)
        Task = WorkflowInstance.Tasks(0)
        ItemList = WorkflowInstance.ParentList
        Item = ItemList.GetItemById(WorkflowInstance.ItemId)
        WorkflowAssociation = ItemList.WorkflowAssociations(WorkflowInstance.AssociationId)

There is a way to obtain these informations directly from the framekork? 
thank you for any response
Rob
Jun 25, 2009 at 2:56 PM

Ok, i've found response from myself: I can use directly the microsoft.sharepoint.workflow framework via the SPContext.Current class. I've created a simple class with some 'magic formulas'.

 

Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Workflow
Imports TPG.SharePoint.Workflow

Public Class TaskInfo
    Public taskItem As SPListItem = SPContext.Current.ListItem
    Public TaskList As SPList = SPContext.Current.Web.Lists(SPContext.Current.ListId)
    Public WorkflowInstanceId As Guid = New Guid(taskItem("WorkflowInstanceID").ToString)
    Public WorkflowInstance As SPWorkflow = New SPWorkflow(SPContext.Current.Web, WorkflowInstanceId)
    Public ItemList As SPList = WorkflowInstance.ParentList
    Public Item As SPListItem = ItemList.GetItemById(WorkflowInstance.ItemId)
    Public WorkflowAssociation As SPWorkflowAssociation = ItemList.WorkflowAssociations(WorkflowInstance.AssociationId)
    Public UrlToItem As String = SPContext.Current.Web.Site.MakeFullUrl((ItemList.RootFolder.Url & "\DispForm.aspx?ID=") + Item.ID.ToString())
End Class
Coordinator
Jun 25, 2009 at 6:52 PM
The workflow association and template can be easily retrieved by casting the ASPX page to IWorkflowPage. I believe there are also two properties on each and every control in our framework that you can use to access this information. I'd need to check on how to access the target list item.

Wouter

________________________________

Van: Interah [mailto:notifications@codeplex.com]
Verzonden: do 25-6-2009 15:57
Aan: Wouter van Vugt
Onderwerp: Re: How can I obtain task related informations? [wss3workflow:60542]



From: Interah

Ok, i've found response from myself: I can use directly the microsoft.sharepoint.workflow framework via the SPContext.Current class. I've created a simple class with some 'magic formulas'.



Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Workflow
Imports TPG.SharePoint.Workflow

Public Class TaskInfo
Public taskItem As SPListItem = SPContext.Current.ListItem
Public TaskList As SPList = SPContext.Current.Web.Lists(SPContext.Current.ListId)
Public WorkflowInstanceId As Guid = New Guid(taskItem("WorkflowInstanceID").ToString)
Public WorkflowInstance As SPWorkflow = New SPWorkflow(SPContext.Current.Web, WorkflowInstanceId)
Public ItemList As SPList = WorkflowInstance.ParentList
Public Item As SPListItem = ItemList.GetItemById(WorkflowInstance.ItemId)
Public WorkflowAssociation As SPWorkflowAssociation = ItemList.WorkflowAssociations(WorkflowInstance.AssociationId)
Public UrlToItem As String = SPContext.Current.Web.Site.MakeFullUrl((ItemList.RootFolder.Url & "\DispForm.aspx?ID=") + Item.ID.ToString())
End Class

Read the full discussion online <http://wss3workflow.codeplex.com/Thread/View.aspx?ThreadId=60542&ANCHOR#Post205431> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[wss3workflow:60542]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings <http://www.codeplex.com/site/discussions/project/unsubscribe/wss3workflow> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com