4

I have a master list (Projects) containing all the data about the projects my clients' employees (technical writers) are working on. When it's time for the writers to grab sign offs on the project they are working on, they run a workflow called, appropriately, "Send for Approvals".

The workflow itself is pretty simple: create some approval tasks for other individuals in the company based on selections made in the Projects list. The only problem is, the writers aren't double checking that they've made accurate selections before sending their items off for approvals, which is creating a huge administrative headache.

So, I've been trying to display the list item information for the specific list item on which the writers are running the workflow on its initiation form, customized in InfoPath 2010.

I know I need the List Item ID in order to do this and, after intense research, it appears that the only place the List Item ID is held during initiation is in the current URL, which is passed as a parameter into the workflow once it starts.

Can I get at that List Item ID in the URL, or is there another way?

Any help is appreciated.

FYI: I cannot use the InfoPath Form Web Part or any VB solutions.

2

3 Answers 3

2

This article seems to be helpful:

Update:
This article seems to refer to SPD2010 workflow on Sharepoint Foundation 2010 while on Sharepoint Server 2010 (and before but not after ( * )) any created workflow is based on Infopath forms. Read, for example in:

All the other (msdn) replies on the issue tell about impossibility to get list item data on a workflow initiation form:

though it is possible to set list item data on the following (not the initial) form:

( * )

On Sharepoint Server 2013 a workflow is impossible to have on Infopath forms

7
  • So, I was reading that blog a couple of days ago (albeit on my phone, since my company has an aggressively unhelpful IT security policy), and the thing I'm having a hard time with is the bit where he's talking about opening the initiation form in SPD. The form is an XSN, so it goes to InfoPath. Forcing it to open in SPD (when that actually worked, the one time), it looked like the markup he described was already in the form. I think I'm going to have to operate under the assumption that there's no way to pass that List Item ID into the initiation form. Commented Nov 21, 2012 at 15:39
  • Probably you should not have customized the Intiation Form in Infopath (having SPD workflow)? Can you try to remove its association with Infopath template if you do not have a lot of customizations: List settings > Form Settings > Use the default Sharepoint form ? You will still have possibiity to get back its association with Infopath template Commented Nov 21, 2012 at 16:17
  • May I ask why have you tagged your question with both "sharepoint-designer" and "infopath" tags? Commented Nov 21, 2012 at 16:50
  • Because the workflow is developed in SharePoint Designer and the initiation form is customized with InfoPath. I figured that if there was a solution to this, it was going to require some finagling in both programs. I'll try reverting the initiation form back to its default, see if the ASPX page is created, get back to you in a bit. Commented Nov 21, 2012 at 17:23
  • Checked both reverting the initiation form to default and checked to see if an ASPX page is created by default with an OOTB workflow. No luck. Everything's dynamically generated from IniWrkflIP.aspx, which appears to be a container for XML data. Commented Nov 21, 2012 at 17:58
0

9) Open page "IniWrkflIP.aspx" with text editor and insert to ScriptEditor WebPart (inside the attribute "Content") following javascript (below) enter image description here

10) JavaScript

    <!DOCTYPE html>
<html>
<body onload="start()">
// <p id="Log">...</p>
<script>
    function start()
    {
        var currentItemId = getURLParameter('ID');
        var currentListId = getURLParameter('List');
        var workflowTemplateId = getURLParameter('TemplateID');
        var elementType = 'input'
        var attributeName = 'title'
        var attributeValue = 'currentItemID'
        var elementObject = findElementByAttributeValue(elementType, attributeName, attributeValue);
        // document.getElementById('Log').innerHTML = 'Item ID: ' + currentItemId + '
List ID: ' + currentListId + '
Workflow template ID: ' + workflowTemplateId + '
Element ID: ' + elementObject.id; if(elementObject !== null) { var elementId = elementObject.id setCurrentItemID(currentItemId, elementId); } } // Get parameters from URL of current item function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])1.replace(/+/g, '%20')) || null; } // Set value to hidden currentItemID InfoPath Field function setCurrentItemID(currentItemId, elementId) { if(document.getElementById(elementId)) { var inputElement = document.getElementById(elementId); inputElement.value = currentItemId; inputElement.setAttribute('value', currentItemId); runControlEvent(inputElement, 'blur');
} } // Get element by specific attribute name and value (i.e. title='currentItemID') function findElementByAttributeValue(elementType, attributeName, attributeValue) { var All = document.getElementsByTagName(elementType); for (var i = 0; i < All.length; i++) { if (All[i].getAttribute(attributeName) == attributeValue) { return All[i]; } } } // Firing event to make postback function runControlEvent(element, controlEventName) { if (document.createEventObject) // for IE { var event = document.createEventObject(); return element.fireEvent('on' + controlEventName, event) } else // for other browsers { var event = document.createEvent('HTMLEvents'); event.initEvent(controlEventName, true, true); return !element.dispatchEvent(event); } } </script> </body> </html>

11) Result enter image description here

0

1) Create input workflow variable/parameter (show on start form)with name "ID" and save the workflow. enter image description here

2) Create/Edit workflow initiation form enter image description here

3) Insert field "ID" to the form (outside the main editable area) enter image description here

4) Important -> Set the SceenTip (i.e. value = "currentItemID") enter image description here

5) Why is it important? Because ID for field/input changes when you change the form (i.e. when you add a new field), but attribute "title" not. enter image description here

6) Open WebFrontEnd server -> path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS" and edit "IniWrkflIP.aspx". (!!Make backup of this file before!!) enter image description here

7) Replace the file contents wit code below:

<%-- _lcid="1033" _version="15.0.4420" _dal="1" --%>
<%-- _LocalBinding --%>
<%@ Assembly Name="Microsoft.Office.Workflow.Pages, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Assembly Name="Microsoft.Office.DocumentManagement.Pages, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Assembly Name="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" DynamicMasterPageFile="~masterurl/default.master" Inherits="Microsoft.Office.Workflow.IniWrkflIPPage"   EnableSessionState="true" AutoEventWireup="false"   %>
<%@ Import Namespace="Microsoft.Office.DocumentManagement.Pages" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Publishing" %>
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %>
<%@ Register Tagprefix="InfoPath" Namespace="Microsoft.Office.InfoPath.Server.Controls" Assembly="Microsoft.Office.InfoPath.Server, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Publishing" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Register TagPrefix="wssuc" TagName="LinksTable" src="/_controltemplates/15/LinksTable.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="/_controltemplates/15/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="/_controltemplates/15/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="LinkSection" src="/_controltemplates/15/LinkSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="/_controltemplates/15/ButtonSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ActionBar" src="/_controltemplates/15/ActionBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="/_controltemplates/15/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="/_controltemplates/15/ToolBarButton.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="/_controltemplates/15/Welcome.ascx" %>
<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:DelegateControl runat="server" ControlId="FormCustomRedirectControl" AllowMultipleControls="true"/>
    <SharePoint:UIVersionedContent UIVersion="4" runat="server">
        <ContentTemplate>
            <SharePoint:CssRegistration Name="forms.css" runat="server"/>
        </ContentTemplate>
    </SharePoint:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
    <SharePoint:EncodedLiteral runat="server" text="<%$Resources:dlc, IniWrkfl_PageTitleGeneric%>" EncodeMethod='HtmlEncode'/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
    <%
    string strPTS = (string)GetGlobalResourceObject("dlc", "IniWrkfl_PageTitleSpecific");
    SPHttpUtility.WriteNoEncode(String.Format(strPTS, SPHttpUtility.HtmlEncode(m_workflowName)),this.Page);
    if (List != null)
    {
        %>: <% if (List.BaseType == SPBaseType.DocumentLibrary)
               { %> <a tabindex=1  id=onetidListHlink HREF=<% SPHttpUtility.WriteAddQuote(SPHttpUtility.UrlPathEncode(m_listItemUrl,true),this.Page);%>><%SPHttpUtility.WriteHtmlEncode(m_listItemName,this.Page);%></A> <% }
               else
               { SPHttpUtility.WriteHtmlEncode(m_listItemName,this.Page); }
    }
    %>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server">
    <img src="/_layouts/15/images/blank.gif?rev=23" width='1' height='1' alt="" />
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
    <%
    string strPageDescription = (string)GetGlobalResourceObject("dlc", "IniWrkfl_PageDescription");
    SPHttpUtility.WriteHtmlEncode(strPageDescription,this.Page);
    %>
</asp:Content>
<asp:Content contentplaceholderid="PlaceHolderSearchArea" runat="server"/>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
    <InfoPath:XmlFormView id="XmlFormControl" runat="server"
        style="width:100%; margin-left:20px;"
        />
    <SharePoint:FormDigest runat=server/>
<br><br>
    <asp:PlaceHolder runat="server" id="ListFormWebPartPlaceHolder"/>
            <%--
    <wssuc:ButtonSection runat="server">
        <Template_Buttons>
            <asp:button class="ms-ButtonHeightWidth" runat="server" text="<%$Resources:wss,multipages_savebutton_text%>" onclick="OKBtn_Click" id="btnOK" />
        </Template_Buttons>
    </wssuc:ButtonSection>
         --%>
    <SharePoint:PageRenderMode runat="server" RenderModeType="Standard"/>
    <SharePoint:UIVersionedContent UIVersion="4" runat="server">
        <ContentTemplate>
            <div style="padding-left:5px">
        </ContentTemplate>
    </SharePoint:UIVersionedContent>
    <table class="ms-core-tableNoSpace" id="onetIDListForm" style="width:90%; margin-left:5px">
     <tr>
      <td>
        <WebPartPages:WebPartZone id="Main" runat="server" FrameType="None" title="loc:Main">
            <ZoneTemplate>
<WebPartPages:ScriptEditorWebPart runat="server" Content="" ChromeType="None" Description="$Resources:core,ScriptEditorWebPartDescription;" ImportErrorMessage="$Resources:core,ImportErrorMessage;" Title="$Resources:core,ScriptEditorWebPartTitle;" __MarkupType="vsattributemarkup" __WebPartId="{311e341a-131c-4987-92e4-50e0bb2d0f7d}" WebPart="true" __designer:IsClosed="false" partorder="2" id="g_311e341a_131c_4987_92e4_50e0bb2d0f7d"></WebPartPages:ScriptEditorWebPart>
            </ZoneTemplate>
        </WebPartPages:WebPartZone>
      </td>
     </tr>
    </table>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
    <ContentTemplate>
    </div>
    </ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderId="PlaceHolderTitleLeftBorder" runat="server">
    <table cellpadding="0" height="100%" width="100%" cellspacing="0">
        <tr>
            <td class="ms-areaseparatorleft">
                <img src="/_layouts/15/images/blank.gif?rev=23" width='1' height='1' alt="" />
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
    <script type="text/javascript" id="onetidPageTitleAreaFrameScript">
        if (document.getElementById("onetidPageTitleAreaFrame") != null) {
            document.getElementById("onetidPageTitleAreaFrame").className = "ms-areaseparator";
        }
    </script>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">
    <SharePoint:StyleBlock runat="server">
        .ms-bodyareaframe {
            padding: 8px;
            border: none;
        }
    </SharePoint:StyleBlock>
</asp:Content>
<asp:Content ID="Content9" ContentPlaceHolderId="PlaceHolderBodyLeftBorder" runat="server">
    <div class='ms-areaseparatorleft'>
        <img src="/_layouts/15/images/blank.gif?rev=23" width='8' height='100%' alt="" />
    </div>
</asp:Content>
<asp:Content ID="Content10" ContentPlaceHolderId="PlaceHolderTitleRightMargin" runat="server">
    <div class='ms-areaseparatorright'>
        <img src="/_layouts/15/images/blank.gif?rev=23" width='8' height='100%' alt="" />
    </div>
</asp:Content>
<asp:Content ID="Content11" ContentPlaceHolderId="PlaceHolderBodyRightMargin" runat="server">
    <div class='ms-areaseparatorright'>
        <img src="/_layouts/15/images/blank.gif?rev=23" width='8' height='100%' alt="" />
    </div>
</asp:Content>
<asp:Content ID="Content12" ContentPlaceHolderId="PlaceHolderTitleAreaSeparator" runat="server"/>

8) This will allow us that the application page is editable and includes a WebPart zone: enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.