Alternative for group by Field snap in Ultra task

Hi,

Can somebody tell me if there is an alternative for the group by field snap? I need to use that functionality in an ultra task and I know that the group by field snap is not compatible. What I need to get at is the following:

Input:

[
{"$id":“1”,“company”:“es”,“accountNumber”:“4351”,“productCode”:“a000000011”,“productDescription”:“prod1”,“netPrice”:0.0,“currency”:“EUR”,“resultMessage”:""},
{"$id":“2”,“company”:“es”,“accountNumber”:“4351”,“productCode”:“a0000021a47”,“productDescription”:“prod2”,“netPrice”:190.630,“currency”:“EUR”,“resultMessage”:""}
}]

Target:

[{“prices”:
[{“materialCode”:“a000000011”,“unitPrice”:0.0,“currency”:“EUR”,“priceType”:“MSD Price”},
{“materialCode”:“a0000021a47”,“unitPrice”:190.630,“currency”:“EUR”,“priceType”:“MSD Price”}
}]
}]

Hope that somebody can help me?
Thanks in advanced.

Hey @Richard,

The Ultra Task is a one record in and one record out service. Any snap that is waiting and collecting all of the documents (Group by, Gate, Sort), will be stuck waiting for the “last document”. There is a workaround, with adding the Group by in a Pipeline execute, but that will not solve your problem if the input in the pipeline is document by document concept.

Hi

Thanks for your answer, just for clarity the input is generated within the ultra task, the ultra task is a REST GET task where we pull prices from our ERP and try to send it back in the result.

If that’s the case, than you can do the workaround with Pipeline Execute

Regards,
Bojan

I’d like to understand your use case better. Which field are you grouping on? In your example you just have 2 inputs becoming one output, yes? What if there are many inputs with different values for the grouping field? You’ll have many outputs. Do all become part of the response of your pipeline?

HI

Yes that is correct.

You can’t return more than one output document per input document from an Ultra pipeline. If your pipeline generates more than one, only the first will be used for the response. You might want to consider a Triggered task instead. It will execute a new pipeline instance for each request so is more flexible.

See the notes under “Output View Type” on this doc page:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/731349232/Planning+Ultra+Pipeline+Tasks