locked
How to associate Pages and Workflow Tasks in SharePoint 2007? RRS feed

  • Question

  • Hi All,

    I had a workflow attached in SharePoint Pages, it triggered on page submit for approval,

    the workflow tasks and history is stored in Workflow Tasks List.

    Now I want associate items in Pages and Workflow Tasks,

    then show in a table consists of columns like Title, Approval Status, Priority, Version and etc.

    e.g: able to get Approval Status and Page version from item in Workflow Task

    I noticed title and ID not able to link the relationship between Pages and Workflow Tasks.

    Any idea how to "link" both together? either by programmatically or DataView WebPart

    Please help, thank you.

    Friday, April 8, 2011 8:14 AM

Answers

  • Yes, I query the tasks list, very simple, but seeing your code above I doubt this helps:

    SPList

    zadaciList = this.Web.Lists["Tasks"];

     

    string query = @"<Where>

    <Contains>

    <FieldRef Name='WorkflowInstanceID' />

    <Value Type='Text'>"

    +wfID+

    @"</Value>

    </Contains>

    </Where>"

    ;

     

    SPQuery q = new SPQuery();

    q.Query = query;

     

    SPListItemCollection kolekcijaZadaci = zadaciList.GetItems(q);

    Zarko
    • Marked as answer by Peng Lei Friday, April 15, 2011 3:08 AM
    Monday, April 11, 2011 7:25 AM

All replies

  • Hi, I recently needed to do something like this. All tasks created from the wf have "WorkflowInstanceID" hidden column populated in the tasks list. On the host list for my wf I created a hidden column WFID and in the initial state of wf populated it with the workflow instance id. Then you can issue a CAML query upon the tasks list, somethin like the code below. I am doing this in an application page which I invoke from ECB menu on the list. Hope this helps.

    <Where><Contains>

    <FieldRef Name='WorkflowInstanceID' />

    <Value Type='Text'>"

    +wfID+

    @"</Value>

    </Contains></Where>

    


    Zarko
    Friday, April 8, 2011 8:35 AM
  • Hi Zarko,

    Thank you from your reply, just wonder what if the situation is in SharePoint Designer 2007 workflow?

    can "Define Workflow Lookup" windows able to locate an unique column and establish a relationship between Pages and Workflow Tasks List?

    Thanks

    Sams

    Friday, April 8, 2011 9:15 AM
  • I am not sure about Designer, sorry.

    Regards


    Zarko
    Friday, April 8, 2011 12:57 PM
  • Hi Zarko,

    I noticed if I query directly from Pages, I not able to get any result,

     

    using (SPSite site = new SPSite(siteUrl))

                {

                    using (SPWeb web = site.OpenWeb())

                    {

                        SPSiteDataQuery q = new SPSiteDataQuery();

                        q.Lists = "<Lists ServerTemplate='850' />";

                        q.Query = @"</Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>";

                        q.ViewFields = "<FieldRef Name='ID' />" +

                                        "<FieldRef Name='Title' />" +

                                        "<FieldRef Name='FileLeafRef' />" +

                                        "<FieldRef Name='FSObjType' />" +

                                        "<FieldRef Name='_UIVersionString' />" +

                                        "<FieldRef Name='Created' />" +

                                        "<FieldRef Name='Author' />" +

                                        "<FieldRef Name='Created' />" +

                                        "<FieldRef Name='Modified' />" +

                                        "<FieldRef Name='_ModerationComments' />" +

                                        "<FieldRef Name='Editor' />" +

                                        "<FieldRef Name='LinkFilenameNoMenu' />" +

                                        "<FieldRef Name='LinkFilename' />" +

                                        "<FieldRef Name='WorkflowInstanceID' />";

                        q.Webs = "<Webs Scope='Recursive'/>";

                        dt = web.GetSiteData(q);

    }

    }

     

    Can you please provide me more details on how you able to query WorkflowInstanceID? is it you query in Workflow Tasks List?

    Thanks

    Sunday, April 10, 2011 11:50 AM
  • Yes, I query the tasks list, very simple, but seeing your code above I doubt this helps:

    SPList

    zadaciList = this.Web.Lists["Tasks"];

     

    string query = @"<Where>

    <Contains>

    <FieldRef Name='WorkflowInstanceID' />

    <Value Type='Text'>"

    +wfID+

    @"</Value>

    </Contains>

    </Where>"

    ;

     

    SPQuery q = new SPQuery();

    q.Query = query;

     

    SPListItemCollection kolekcijaZadaci = zadaciList.GetItems(q);

    Zarko
    • Marked as answer by Peng Lei Friday, April 15, 2011 3:08 AM
    Monday, April 11, 2011 7:25 AM