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

Format multiple list items for email

Hi everyone,

I am creating my first Nintex workflow and thanks to a couple very helpful people on these discussion boards am close to completion.  The last thing I need to build is a system for sending out the status of the items in the list in a weekly update email so that it can be printed out and disiplayed for everyone to see what is happening with the items they submitted.  I have googled and found some articles on how to compile items into a table and email them but even these are a bit too advanced for me to work through alone.

Could anyone help me get started?  I am trying ot implement the method discussed in the article linked below but do not know how to start by storing my data in a multiline field as xml (excerpt quoted below).  I am just using a simple list and single workflow built on that list, no Nintex Forms.

http://www.sharepointpub.com/formatting-a-table-from-collection-variables-nintex-workflow/

"First thing we need to do is to create some collection variables and populate them with data.. In my example I’m using Nintex Forms and some repeating section controls. These control store the multiple rows of information into a multiline field as xml. This allows me to use the ‘Query XML‘ action to get the values out and store them into a collection variable."

Thank you for any direction you can provide.

Labels: (2)
Reply
6 Replies
Not applicable

Re: Format multiple list items for email

If this is your first Nintex workflow then the method I'm suggesting may be too complicated for your scenario, but exactly for this kind of task a combination of web services (GetListItems of Lists.asmx) and XSL would be the perfect fit  (I made very good experiences with it and it simplifies the workflow a lot, except the kind of "complicated" actions of course).

With this approach you'd only need three actions in the workflow:

  • Call a web service (http://yoursite/_vti_bin/Lists.asmx, method GetListItems)
    This returns the list content in XML format
  • Query XML
    With this action you re-format the XML from the previous action to fit your needs with an XSL stylesheet
  • Send email notification
    Send an email with the output of your Query XML action

Vadim Tabakman wrote an excellent post for this method Nintex Workflow - XSL Transformation - Vadim Tabakman which was the starting point for me (I did not know anything about XSL before).

Reply
Not applicable

Re: Format multiple list items for email


Hi Martin, thanks a lot for the reply.

In the Call Web Service action, if I want to return all items from a certain list and view and use listName and viewName, do I need to use any of the other fields to specify anything?  And what do I store the output in?  A variable of type multiple lines of text?

It seems like in your attached tutorial the creator does everything within the call web service action.

I appreciate the help and understand if you don't have the time to walk me through this.

0 Kudos
Reply
Not applicable

Re: Format multiple list items for email

To be honest, when I created this example I realized that the "Call a web service" action is far more complicated than I remembered (I'm doing these steps automatically, so I don't "realize" anymore what an effort it is... ).

Ok, we have a list with the (internal) field names "Title" and "Status".

step-01.png

Add a "Call a web service" action to your workflow, use "Web URL" (Common Workflow Variable) and "/_vti_bin/Lists.asmx" as the URL, enter your credentials (best practice is to use a service account here) and press the "Refresh Button".

step-02.png

The drop down will be populated, select "GetListItems" from the list.

Now, unfortunately the SOAP created by the simple Nintex mask (=SOAP Builder) is buggy, so you have to change to "SOAP editor" and edit the SOAP manually. So, switch to "SOAP editor", the single text fields disappear and you have a multiline textbox with the complete SOAP.

Edit the parameters as shown below.

step-03.png

Note, I'm always using the IDs of the list and the view  (including the curly brackets), since a list and a view name can be changed, but not the ID. A great tool to get the ID (and for other things) ist the "Stramit CAML Viewer 2007": http://spcamlviewer.codeplex.com/

Enter empty nodes for "<ViewFields />" and "<QueryOptions />", otherwise you will get a "Root node missing" error when running the workflow (this is the buggy part of the SOAP builder).

If your default view contains all the elements you want to send, you can leave <viewName> empty. You don't need any other values, check out http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx for their meaning.

You can run the action now (use the "Run now" button) and you already should get back the XML of your list items.

step-04.png

Now for the hard part, the XSLT...

You can take the example Vadim Tabakman is providing in his blog entry and modify it to your needs. The key thing to remember is that you access the field values by using the internal field name and the prefix "@ows_" (@ because they're attributes).

So to first find all your rows, you use the xpath query "//z:row" and inside the z:row template you're accessing the values with <xsl:value-of select="@ows_Title" /> or <xsl:value-of select="@ows_Status" /> . So, in our example the stylesheet would look like this:

step-05.png

And the output would be:

step-06.png

And yes, you're right, you can do everything in only two steps. For this add the XSL in the box below "Result processing" in the "Call a web service action"  (do not tick "Force top level XML node") and save the output in a multiline variable.

This variable contains the HTML which you can use in your email body in the "Send notification" action.

I attached the stylesheet I used for this example and the workflow (with the "Call a web service" action only) as well.

Reply
Not applicable

Re: Format multiple list items for email

Hi Martin,

I can't thank you enough for this in depth explanation.  You have gone above and beyond to simplify this for me.

I am sorry for taking so long to get back on this, I hope you might still be available to help.  When I use the "Run Now" button nothing is being returned in the results field.  I had to use the actual list name and view name because I am getting an error when trying to use the tool you provided to procure the ID's.

Do you perhaps see some silly error I am making?  Unfortunately I have to admit I am just trying to match up your stuff to fit mine without really understanding much.


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


<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">


  <soap:Header>


  </soap:Header>


  <soap:Body>


    <m:GetListItems>


      <m:listName>Submit Change Request</m:listName>


      <m:viewName>ECR Submissions</m:viewName>


      <m:query>


      </m:query>


      <m:viewFields>


         <ViewFields />


      </m:viewFields>


      <m:rowLimit>0</m:rowLimit>


      <m:queryOptions>


            <QueryOptions />


      </m:queryOptions>


      <m:webID>


      </m:webID>


    </m:GetListItems>


  </soap:Body>


</soap:Envelope>



Best,

John

Reply
Not applicable

Re: Format multiple list items for email

Hi John

You're welcome...

No, I don't see an error in your XML at first sight. What you mean by "nothing is returned on 'Run now'"? Is the result box completely empty or do you have the result XML but no rows inside it?

To get the list (and view) ID I just found another little helper tool: http://meyerweb.com/eric/tools/dencoder/, where you can just enter the URL and it will decode the IDs for you (go to your list and the view you want to query, click on "Modify View" and copy this URL into the text box on the "URL Decoder/Encoder" page.

Maybe it works with the IDs, but to be honest, at the moment I don't see the problem. Do you see list items when you call this view in the browser?

Regards,

Martin

0 Kudos
Reply
sjnbham
Nintex Newbie

Re: Format multiple list items for email

Brilliant! Worked perfectly. I used the List and View GUIDs with success:

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

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">

  <soap:Header>

  </soap:Header>

  <soap:Body>

    <m:GetListItems>

      <m:listName>{45F2E1DF-3223-465B-9551-46F267660FFD}</m:listName>

      <m:viewName>{A4C44C7F-274F-4152-886A-DD4702C74D15}</m:viewName>

      <m:query></m:query>

      <m:viewFields><ViewFields /></m:viewFields>

      <m:rowLimit>0</m:rowLimit>

      <m:queryOptions><QueryOptions /></m:queryOptions>

      <m:webID></m:webID>

    </m:GetListItems>

  </soap:Body>

</soap:Envelope>

I just copied the XSLT in the example for my initial testing to ensure it worked, and it did.

Reply