cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Get context data at the Workflow Start form

Jump to solution

Using Nintex Workflows 2010, at the start of the workflow (infopath), we need to get the context item id. This is given when using a task form within the workflow (NWContext). However, this is not available on the workflow start form. Any ideas!?

Labels: (2)
Tags (1)
0 Kudos
Reply
5 Replies
Highlighted
Workflow Hero

Re: Get context data at the Workflow Start form

Jump to solution

I searched around and it seems the same question was fired on Nintex Connect...but no answers there either.

Nintex Connect - No NWContext in InfoPath form at start forms

0 Kudos
Reply
Not applicable

Re: Get context data at the Workflow Start form

Jump to solution
0 Kudos
Reply
Workflow Hero

Re: Get context data at the Workflow Start form

Jump to solution

I know this has been open a while, but just in case people are still looking.

I've been trying to do the same, Nintex Support have said you need update the Workflow Manage Context Data screen in Central Admin. Now I'm trying to find the fully qualified field names to enter as help guide only says you can add or delete context data fields.

0 Kudos
Reply
Workflow Hero

Re: Get context data at the Workflow Start form

Jump to solution

Official answer from Nintex support - Infopath start forms do not get the nwcontext file by design as some fields are inappropriate (e.g. approver comments).

I've raised a request on nintex.uservoice.com for an appropriate version of the file to be added for start forms - supporting votes appreciated

0 Kudos
Reply
Workflow Hero

Re: Get context data at the Workflow Start form

Jump to solution

InfoPath Workflow Initiation form - Get context for current item (On Premise solution)

  • Create input workflow variable/parameter (show on start form)with name "ID" and save the workflow.

  • Create/Edit workflow initiation form
  • Insert field "ID" to the form (outside the main editable area)
  • Important -> Set the SceenTip (i.e. value = "currentItemID")

  • 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.

  • 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!!)

  • 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"/>

 

  • This will allow us that the application page is editable and includes a WebPart zone:

  • Open page "IniWrkflIP.aspx" with text editor and insert to ScriptEditor WebPart (inside the attribute "Content") following javascript (below)
  • JavaScript


&lt;!DOCTYPE html&gt;

&lt;html&gt;

&lt;body onload=&quot;start()&quot;&gt;

// &lt;p id=&quot;Log&quot;&gt;...&lt;/p&gt;

&lt;script&gt;

    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 + '<br>List ID: ' + currentListId + '<br>Workflow template ID: ' + workflowTemplateId + '<br>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('[?|&amp;]' + name + '=' + '([^&amp;;]+?)(&amp;|#|;|$)').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 &lt; All.length; i++)

        {

            if (All.getAttribute(attributeName) == attributeValue)

            {

                   return All;

            }

        }

    }

    // 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);

        }

    }

&lt;/script&gt;

&lt;/body&gt;

&lt;/html&gt;

 

  • Result

0 Kudos
Reply