cancel
Showing results for 
Search instead for 
Did you mean: 
asadki
Nintex Newbie

Query List and send Items by email in a workflow

Hi All;

Is there a way to query a list and send all Items output by email (one email with all items)? I have tried to put the output into a collection variable and send it by email, but the result is not good for me, i can not manage this output.

i got something like :

[{"Title":"server1","WarrantyExpirationDate":"2017-05-20T04:00:00Z"},{"Title":"server2","WarrantyExpirationDate":"2017-06-03T04:00:00Z"}]

any idea how i can get the output like :

server name | Warranty expiration date

or if i can put the result into a document using document generation ! i don't know how to loop into a document generation action so i can get all items ! any how-to ?

Thank you in advance.

Labels: (1)
0 Kudos
Reply
5 Replies
seid
Nintex Newbie

Re: Query List and send Items by email in a workflow

Yes that's possible and fairly easy! 

Query your list items using a Query List Action and store the IDs in a collection variable. Then use a Foreach Loop Action to iterate through each ID in the collection. Again use a Query List Action to retrieve the required data from the list. Then inside the loop use a Build String action to get the desired output in your case it is something like this: "[{"Title":"server1","WarrantyExpirationDate":"2017-05-20T04:00:00Z"},{"Title":"server2","WarrantyExpirationDate":"2017-06-03T04:00:00Z"}]"

Finally after the loop ends you can add your Email Notification Action and set the body of the email to the variable of Build String action.

Reply
asadki
Nintex Newbie

Re: Query List  and send Items by email in a workflow

Hi Shaikha and thank you for your response;

the build string variable after the loop keeps only the last loop variables (not all of them), any idea how to keep all variables !!

 my workflow :

i got only the last iteration variable : 

 

any idea how to get both iterations at one String/variable ?

thank you fro your help in advance;

Ahmed

Reply
rogelio_tan
Nintex Newbie

Re: Query List and send Items by email in a workflow

Hi Ahmed,

Put the Output Variable DeviceName_expdate to the string input also. so that the previous value will be stored properly. Hope this helps. 

0 Kudos
Reply
asadki
Nintex Newbie

Re: Query List and send Items by email in a workflow

Hi Rogelio; thank you for your response;

i don't have only 2 records in my loop, i have a query list which have a collection output, then i have to loop/for each  record in this collection. so i don't know how many records i will have. in that example i have 2 record and i want to store each field of the collection in a variable and after the loop send all items/variables in one email.

here is simple example :

list : Server    | Exp Date

         Server1 | 12/01/2012

         Server2 | 03/02/2015

         Server 3|  02/06/2017

         server4  | 05/12/2016

- How to create a workflow that send all this items in "one" email; (if you just use a collection variable the output/print is not good, i got something like

[{"Title":"server1","WarrantyExpirationDate":"2017-05-20T04:00:00Z"},{"Title":"server2","WarrantyExpirationDate":"2017-06-03T04:00:00Z"}]").

thank you for your help!

Ahmed

0 Kudos
Reply
seid
Nintex Newbie

Re: Query List  and send Items by email in a workflow

Hi Ahmed.

Inside your Build String action you should add the build string variable at the end so each time the loop runs it doesn't overwrite the variable values. 

The for each loop will run for all the IDs stored in the collection therefore you need not to know how many items there.

But one question I have. What type of variable are you using to store the items is it single line or multi-line? 

0 Kudos
Reply