Sharepoint Workflow column not available - InfoPath Dev
in

InfoPath Dev

Sharepoint Workflow column not available

Last post 01-16-2013 02:24 AM by renato. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-25-2011 05:22 AM

    • renato
    • Not Ranked
      Male
    • Joined on 12-02-2010
    • Romano
    • Posts 16

    Sharepoint Workflow column not available

    I want my forms to react to their workflow status; in order to do that, after defining a built-in approval workflow on the library, I created a secondary data connection to retrieve the workflow status, however the status column is not shown on the data connection wizard among available columns for the library.

    Apparently, Sharepoint itself does not show the workflow status column on the library settings page, though it is shown in the library content, and in view definitions. This method seem to be suggested on several forums and articles, and on the microsoft site itself, so apparently there should be a workaround (other than using a web service call, assuming that will work...)

    Any help is really appreciated,

    Renato

  • 02-02-2011 01:28 PM In reply to

    Re: Sharepoint Workflow column not available

     i have the same problem, any suggestions?

  • 02-02-2011 02:08 PM In reply to

    Re: Sharepoint Workflow column not available

     i found a way to do this:

     http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/e46db7b9-e6fa-4cb2-9b47-6dd44c32aeaf

  • 02-03-2011 05:00 AM In reply to

    • renato
    • Not Ranked
      Male
    • Joined on 12-02-2010
    • Romano
    • Posts 16

    Re: Sharepoint Workflow column not available

    I didn't want to design a brand new workflow, since the default Approval was fine for me. The only way I found to manage this was by manually calling the Lists.GetListItems web service method and query for the workflow status column. In case you do that, be aware that the value returned is an integer with the following mapping:

    2 = In Progress

    5 = Completed

    15 = Canceled

    16 = Approved

    17 = Rejected

    Nothing (Empty, or no attribute at all) the workflow has not been started yet.

  • 01-15-2013 02:33 PM In reply to

    • vindog
    • Not Ranked
    • Joined on 01-15-2013
    • Irvine, California
    • Posts 2

    Re: Sharepoint Workflow column not available

    Hi I saw somewhere that a webservice could be used in making a Data connection to the list for this purpose; but I can't find that article or how to do it. Is that what you did? And can you give some more detail if so? I don't have access to SP Designer either..just infopath designer... thank you vin
    Vin
    -------------------------------------------
    not a developer, but a SharePoint fan..
  • 01-16-2013 02:24 AM In reply to

    • renato
    • Not Ranked
      Male
    • Joined on 12-02-2010
    • Romano
    • Posts 16

    Re: Sharepoint Workflow column not available

    Using a web service call worked for me, but you will at least need VSTA (Visual Studio Tools for Applications) in order to run some code behind the form. You should be guided to download it if you click on any code editing button associated to a form' control.

    Once there you'll need a reference to the "lists" web service on your SP site (http://spsiteserver/spsitepath/_vti_bin/lists.asmx?WSDL), then the code to query your list and retrieve the "Approval" column: some (hopefully helpful) clarifications:

    • "listsWS" is the web reference name to the "lists" web service;
    • I'm querying the list using a "projectID" and "GateNumber" keys (select the list item where projectID = X and GateNumber = Y) because this makes sense in my scenario, you'll probably need to define a different criteria to identify the "current" form;
    • You will need the GUID of both the library and the view you want to query; in my case I had an additional requirement to query one library or another, so the code here down decides which one to query based on the value of the "location" form field;
    • to retrieve GUID for your list and view, just google the question, there are many different ways (but consider that if you have separate development, test and production environments, those GUIDS are likely to change among them);
    • the final "decodeApprovalStatus" call just maps integers to strings with the mapping above in this thread

    In the form' onLoad method I then call this gatherFormStatus and store the output into a hidden form field; based on that value I then show an "Approved" (or "Rejected", and so on) string/image/whatever you prefer in the form.

    Hope it helps,

    private string gatherFormStatus()
            {
                listsWS.Lists lists = new listsWS.Lists();
                lists.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                XmlDocument doc = new System.Xml.XmlDocument();
                string projectID = thisXDocument.DOM.selectSingleNode("/my:myFields/my:ProjectSummaryInformation/my:projectID").text;
                doc.LoadXml("<Document><Query><Where><And><Eq><FieldRef Name=\"Project_x0020_ID\" /><Value Type=\"Text\">" + projectID + "</Value></Eq>" +
                    "<Eq><FieldRef Name=\"Gate_x0020_Number\" /><Value Type=\"Text\">3</Value></Eq></And></Where></Query><ViewFields/><QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions></Document>");
                XmlNode listQuery = doc.SelectSingleNode("//Query");
                XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
                XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
                XmlNode res;
                // this method is only invoked when the form is NOT new (i.e. user is opening an already submitted form); hence we do have the
                // location and can use to decide if should query the NdG library or the "regular" library:
                string formLocation = thisXDocument.DOM.selectSingleNode("/my:myFields/my:ProjectSummaryInformation/my:GeneralInformation/my:location").text;
                string library = ("NdG".Equals(formLocation) ? NdGlibraryID : libraryID);
                string viewID = ("NdG".Equals(formLocation) ? NdGsystemViewID : systemViewID);

                try
                {
                    res = lists.GetListItems(
                        library,
                        viewID,
                        listQuery,
                        listViewFields,
                        null,
                        listQueryOptions,
                        null);
                    // Method signature:
                    // lists.GetListItems(String ListName, String viewName, XmlNode query, XmlNode viewFields, string rowLimit, XmlNode queryOptions, String webID);
                }
                catch (Exception e)
                {
                    thisXDocument.UI.Alert("There has been an error during data exchange with Sharepoint: \n" + e.Message);
                    return "Approved"; // Approved; if status cannot be retrieved, lock the form
                }
                XmlDocument resultsDoc = new XmlDocument();
                XmlNamespaceManager ns = new XmlNamespaceManager(resultsDoc.NameTable);
                ns.AddNamespace("z", "#RowsetSchema");

                XmlNodeList rows = res.SelectNodes("//z:row", ns);
                string statusCode = "0";
                if (rows.Item(0).Attributes["ows_Approval"] != null)
                {
                    statusCode = rows.Item(0).Attributes["ows_Approval"].Value;
                }
                return decodeApprovalStatus(statusCode);
            }

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.