[Combining Multiple Outputs from data model (grouped by a name) into Single Email]

Disclaimer: A complex scenario to explain in text, but giving it a try here
A customer wants to aggregate output from 3 query data modules and send them in s single email…
The output from each module is based on some conditions and all of them cannot be combined into a single query data module and hence using 3 different QD modules
this is how the action flow is configured with the three QD modules tied to a “text aggregator” for each condition (see screenshot 1)

the output from the 1st module is as shown … (screenshot 2)

the output from the aggregators is to be grouped by a Manager and at the end… a single email is to be send to this manager with all the bundles under his name…
since the text aggregator might have 2 or more bundles, the subsequent module is being executed multiple times… to avoid this, I used another text aggregator to combine the output from previous aggregator (see screenshot 3),

but in this case I cannot further group the bundles by a Manager…
Has someone been in a similar situation before ?

ultimately with my current setup I am able to achieve this
The 3 tables from 3 conditions combined together which has Jobs for all the 3 PSD Managers.

The expectation is for eample, the jobs for Tariq Javed (one of the PSD Managers) are to be combined from condition 1 (table 1) and condition 2 (table 2) and to be sent in a single email.
Note: It is not always the same PSD Managers, so the filters if used should be dynamic

Hi @Swarup_Alamuru ,

Thank you for the detailed explanation. I have one more question. Do the 3 queries return the same data format, or are they all 3 different?

Glenn - Callinetic

Hi @Callinetic , 2 of them have the same data format but one has a different format as was shown on the screenshot.
Condition 1 : Job End But Ticket not Created
Condition 2: FT Pending Approval
Condition 3: FT created but Not Submitted

You could replace the text aggregators with array aggregators, without grouping the values. Create the different arrays, then merge them and iterate over them. After the iteration, aggregate the text and group it by manager. The bundles outputted by the aggregator are then also per manager, so you can immediately set the value as the text of your email.
I attempted to reproduce and minimize your workflow, and this is the result.


I also uploaded the blueprint of it. (Data is randomly generated so no worries)
blueprint (7).json (19.6 KB)

To dynamically create your text, as you attempted to do in your scenario, you can use functions in your text aggregator to determine which query the object was returned from. For example, based on a key that exists in format A but not in B.

I hope I understood your use case correctly and this answers you question.
Glenn - Callinetic

2 Likes

Thanks so much Glenn. This helped.
I still have some doubt on the last part on how I can fetch data with different structures on the iterator output.
For example, I have the below structures with different key as highlighted. I understand that the map function works only with arrays. Do you have any suggestion which function I can use here ?

Hi @Swarup_Alamuru ,

Good question!
Because the parameter is not always present in each bundle, we need to apply a small trick here.

Firstly,…
Each variable that you map can also be entered in the mustache format. So if you for example past {{newline}} in a mappable field, you’ll notice that it will be transformed into the newline option you can select in the text functions tab.

It’s helpful to give you a bit of context about this, because you’ll need to use it as well. As I mentioned before, you’ll need to determine if a certain parameter exists in the object to build your text structure. So once you have identified these keys, you can reference them. I see your bundle outputs have neat labels, so you should first check what the technical key is by hovering over the name. Then, in your text aggregator, create your IF statement. Reference the right keys to check if they exist by applying the format {{<module number>.<technical key name>}}. So for example: {{29.jobEndAndTicketNotCreatedDate}}. Once added, you’ll notice that the background of that variable is not filled. That’s because it’s not found in the interface of the module you’re linking to.
Also, check this link when your technical key names contain spaces.Closing brackets to insert item –> }} - #2 by Callinetic
image

I extended the example I previously sent. I added a element newElement in the second JSON parsing module to the first object. Because of my IF statement in the text aggregator, I get the following output now.

blueprint (52).json (18.9 KB)

I hope this makes sense despite being a bit complicated.
Glenn - Callinetic

3 Likes

Perfect, this helped a lot. Thanks so much Glenn. You are awesome :slight_smile:

2 Likes

Is @Callinetic 's response a solution to your post? If so can you mark it as a solution to the topic?

1 Like