cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Nintex repeating section

Jump to solution

Hi Friends,

 

I'm using repeating section and this is the sample code generated

 

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><TypeofWork type="System.String">Follow Up</TypeofWork><TimeTaken type="System.Double">12</TimeTaken></Item><Item><TypeofWork type="System.String">Transferred</TypeofWork><TimeTaken type="System.Double">12</TimeTaken></Item><Item><TypeofWork type="System.String">Meeting</TypeofWork><TimeTaken type="System.Double">12</TimeTaken></Item><Item><TypeofWork type="System.String">Follow Up</TypeofWork><TimeTaken type="System.Double">12</TimeTaken></Item></Items></RepeaterData>

 

In the code, there are two rows of data that contains Follow up as the Type of work along with the Time Taken for each status

 

Is it possible(either using code or workflow) to gather/add/group the time taken information based on the Type of Work? For ex.: If the Type of work = Follow Up then the output should be 24.

 

This is the XSLT Code, I'm using

 

<?xml version="1.0"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

        <!-- transform repeating section from xml to html -->

        <xsl:template match="/">

            <xsl:apply-templates />

        </xsl:template>

       

        <xsl:template match="Items">

             <table border="1" width="100%" style="border-collapse:collapse;background-color:#eee;border:1px solid;color:black;font-size:100%;font-family:arial,helvetica,sans-serif;">

                 <thead>

                     <tr>

                         <td>Type of Work</td>

                         <td>Time Taken</td>

                     </tr>

                 </thead>

                 <tbody>

                     <xsl:apply-templates />

                 </tbody>

             </table>

        </xsl:template>

       

        <xsl:template match="Item">

             <tr>

                 <!-- field output order -->

                 <xsl:apply-templates select="TypeofWork" />

                 <xsl:apply-templates select="TimeTaken" />

             </tr>

        </xsl:template>

       

                <xsl:template match="TypeofWork">

             <td>

                 <xsl:value-of select="." disable-output-escaping="yes"/> </td>

         </xsl:template>

  

         <xsl:template match="TimeTaken">

             <td>

                 <xsl:value-of select="." disable-output-escaping="yes"/> </td>

        </xsl:template>

       

</xsl:stylesheet>

Labels: (2)
0 Kudos
Reply
13 Replies
mlauer
Nintex Newbie

Re: Nintex repeating section

Jump to solution

I think You can do it with a Query XML action in Workflow.

For XSLT 1.0 You have to use a method called Muenchian grouping.

You will get examples by searching the web for: XSLT 1.0 grouping summing

Kind regards

Manfred

0 Kudos
Reply
cju
Nintex Newbie

Re: Nintex repeating section

Jump to solution

It's possible to do that with a Nintex Workflow.

You will have to use a temporary list to do that with two columns : the Title and a number column.

In the workflow, you can use the Query XML action to extract the type of work and the time taken using the following two XPath queries (in one Query XML action you can add several outputs) :

//TypeofWork

//TimeTaken

Configure the Query XML action to store the result of each expression in a different collection variable (one collection variable for the type of work and another one for the time taken)

Then you can perform a foreach action on the type of work collection variable (store the index in a number variable).

In the foreach :

  • you can use the collection operation action to get the time taken corresponding to the current type of work by configuration the collection operation like the following :
    • Target collection : time taken collection variable
    • Operation : Get
    • Index : index number variable
    • Store result in : create a new text variable
  • Then you can use a query list action to check if a line with the same Title as the current type of work exist (retrieve the ID and the number columns) in the temporary list
  • If it already exists (the retrieved ID is greater than 0), then you can add the current time taken (you need to first convert it to number with a Convert value action) with the retrieved number column by using a Math operation action and update the number column with the result from the math operation in the temporary list item which ID equals the retrieved ID
  • If it doesn't exist, create an item in the temporary list with the Title equals the current type of work and the number column equals the current time taken (you need to first convert it to number with a Convert value action)

In the temporary list you will have what you need.

If you need to update the XML in the repeating section, you can query the temporary list using a query list action and build a new XML.

Once it's done, you can delete all the items added in the temporary list.

Hope this helps

0 Kudos
Reply
cju
Nintex Newbie

Re: Nintex repeating section

Jump to solution

Sorry I didn't see your answer.

It's an easier solution than mine !

0 Kudos
Reply
Not applicable

Re: Nintex repeating section

Jump to solution

Hi Manfred,

Thank you for the reply. However, I'm unable to group / sum the values using XSLT. If possible, for you to suggest the changes for the above mentioned XLST code?

0 Kudos
Reply
Not applicable

Re: Nintex repeating section

Jump to solution

Hello Caroline,

Thank you for the reply. I'm really new to this workflow, so can you please elaborate / provide step by step process of creating the workflow? I'll then try and reach out to you if I'm unable to replicate it.

0 Kudos
Reply
cju
Nintex Newbie

Re: Nintex repeating section

Jump to solution

Hi,

Can you precise what is not clear for you ?

Have you tested the query XML action ?

0 Kudos
Reply
Not applicable

Re: Nintex repeating section

Jump to solution

Hi,

The above mentioned process is a bit complex, so would really appreciate if you could simplify it for me

For example.: I would like to store the Time Taken data along with the Type of Work in the same list. So I assume that first I need create a number variable and assign the default value to 1000. Next use Query List action and store the data in multiple line of text or in a collection variable? What would be the next process etc etc.....

0 Kudos
Reply
cju
Nintex Newbie

Re: Nintex repeating section

Jump to solution

ok, I will try to be more precise.

Here are the actions that you should use in the workflow, for the number variables, you can set the default value to 0 :

  • Query XML :
    • Output 1 :
      • process using : XPath
      • XPath query : //TypeofWork
      • return results as : text
      • store result in : type of work collection variable
    • Output 2 :
      • process using : XPath
      • XPath query : //TimeTaken
      • return results as : text
      • store result in : time taken collection variable
  • For each :
    • target collection : type of work collection variable
    • store result in : current type of work single line of text variable
    • index : index number variable
  • In the for each :
    • Collection operation :
      • target collection : time taken collection variable
      • operation : Get
      • index : index number variable
      • store result in : current time taken single line of text variable
    • Query list :
      • list : temporary list
      • Filter : select items only when the following is true :
        • Show the item when column : Title is equal to current type of work single line of text variable
      • Field :
        • ID : temporary item ID single line of text variable
        • Number column : temporary item number single line of text variable
    • Set a condition :
      • Condition : If any value equals value
      • Where : workflow data : temporary item ID single line of text variable
      • is not empty
    • Yes side of the condition :
      • Convert value :
        • Input : temporary item number single line of text variable
        • Store result in : temporary item number number variable
      • Convert value :
        • Input : current time taken single line of text variable
        • Store result in : current time taken number variable
      • Math operation :
        • Calculation : worflow data : current time taken number variable
        • Plus
        • worflow data : temporary item number number variable
        • Store result in : current total time taken number variable
      • Update item :
        • Update : temporary list
        • Where : ID equals : workflow data : temporary item ID single line of text variable
        • Field : Number column : equals : workflow data : current total time taken number variable
    • No side of the condition :
      • Create item :

        • Create item in : temporary list

        • Field :

          • Title : current type of work single line of text variable

          • Number column : current time taken single line of text variable (if there is an error at the item creation, you should first convert this variable to number)

    • Commit pending changes
  • Query list :

    • list : temporary list

    • Filter : select all list items

    • Field :

      • Title : temporary items title collection variable

      • Number column : temporary items number collection variable

  • Build string :

    • Text : <?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items>

    • Store result in : XML single line of text variable

  • For each :

    • target collection : temporary items title collection variable

    • store result in : current temp item title single line of text variable

    • index : index number variable

  • In the for each :

    • Collection operation :

      • target collection : temporary items number collection variable

      • operation : Get

      • index : index number variable

      • store result in : current temp item number single line of text variable

    • Build string :
      • Text : {WorkflowVariable:XML single line of text variable}<Item><TypeofWork type="System.String">{WorkflowVaiable:current temp item title single line of text variable}</TypeofWork><TimeTaken type="System.Double">{WorkflowVariable:current temp item number single line of text variable}</TimeTaken></Item>
      • Store result in : XML single line of text variable
  • Build string :
    • Text : {WorkflowVariable:XML single line of text variable}</Items></RepeaterData>
    • Store result in : XML single line of text variable

In the XML single line of tex variable, there's the new repeating section data, you can update your current item with it.

Hope this helps

0 Kudos
Reply
mlauer
Nintex Newbie

Re: Nintex repeating section

Jump to solution

Using stylesheet below You will get as result of XML Query action:

 

Follow Up=24;Meeting=12;Transferred=12;

 

 

Stylesheet:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xslSmiley Surprisedutput method="html" />

   <!-- Add an index (key) that allows selection based on the value of TypeofWork -->

   <xsl:key name="X" match="Item" use="TypeofWork" />

   <xsl:template match="/">

      <!-- The for-each selects the first Table node for every unique xpos value. 

         In other words, the for-each will iterate exactly once for each unique

         value of TypeofWork. -->

      <xsl:for-each select="//Item[generate-id(.)=generate-id(key('X', TypeofWork)[1])]">

         <xsl:sort select="TypeofWork" />

         <xsl:variable name="XGroup" select="key('X', TypeofWork)" />

         <xsl:value-of select="TypeofWork" />

         <xsl:text>=</xsl:text>

         <xsl:value-of select="sum($XGroup/TimeTaken )" />

         <xsl:text>;</xsl:text>

      </xsl:for-each>

   </xsl:template>

</xsl:stylesheet>

 

Kind regards

Manfred

0 Kudos
Reply