0

I am trying to build a Pipeline which queries out my Sales records (as one Read activity) Now in this Sales schema there are fields that reference a People table however its not a direct connection as there is a Many-to-Many relationship.

So what I need to do is query my PeopleToSales table for all related records and populate them in a flat structure in my subsequent JSON object.

How can I built two objects together and join them based on Sales ID? Also in the event there are multiple matches how can I choose the first one?

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
InvalidSyntax
  • 9,131
  • 20
  • 80
  • 127

1 Answers1

0

You can read both the Sales records and the PeopleToSales table and then use the Join snap to merge the relevant documents based on whatever ID that defines the relation between them.

After that, you can use the Group By Fields snap to group the documents based on Sales ID.

You can add the Sales ID field (say - $sales_id) in the Fields list in the settings and it will group documents based on the Sales ID.

Also, when using the Group By Fields snap, you first have to sort the documents based on the keys. So, use a Sort snap before the Group By Fields snap.

As far as getting the first object is concerned, after the group-by, you can just get the 0th element of the list (say group[0]).

Please refer to - SnapLogic Docs - Group By Fields

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58