3 weeks ago
Hi All,
I would like some advice/better solution to my query!
I am preparing some data to send in a table via email, the data structure is as below
[{ "statusCode": 202, "statusText": "Accepted", "payload_file_name": "s3:///bucket/api-payload/archive/api_payload_20241023_140821324_j1.json", "receivedDate": "2024-10-28T13:25:26.6271537Z", "processedDate": "2024-10-28T13:25:26.6271537Z", "rowsCount": 2, "transactionId": "{a0aa71d8-5c0a-4bdc-a39f-a42bf5143c3b}" }]
I am preparing the fields in a parent pipeline and feeding the data as a string to a child, a mapper creates this using data.field_name formatting and "data" is passed as the pipeline parameter.
When the child receives this, I am having some trouble getting the below tweaked code (from another post by @koryknick) to map the fields from horizontal to vertical format (easier to read in a quick email notification)
$email_data.entries().slice(0).map(x=> { "Field": x[0], "Value" : x[1] }
This code works fine directly in line with the mapper snap creating the data.field_name data, but when passed to a child, it gives it a set of square braces [...], and the code no longer works as it did. I have tried many forms of grouping and mapping, and come up with what I think is a hacky solution, which something better could replace.
My solution is simply to replace the [ and ] characters to nothing (.replace('[','')) in the incoming string to the child pipeline. I'm convinced there is a better way to do this with the expression language, but can't figure it out!
Without the replacing of the square braces
I've attached a sample pipeline with the mapping and payload as a parameter.
Thanks in adance!
Solved! Go to Solution.
3 weeks ago
@LeeDuffy - if I read your post correctly, you are passing data as a pipeline parameter; this is against best practice. Instead, I recommend that you leave the input view of your first snap in your child pipeline open, which will allow the data payload to be passed to the child as if it is part of the parent pipeline - no formatting or parsing necessary.
Hope this helps!
PS - you did not attach your sample pipeline, so I interpreted as best I could. If you are having difficulty attaching the SLP file, you can just zip it and attach the zip file.
3 weeks ago
@LeeDuffy - if I read your post correctly, you are passing data as a pipeline parameter; this is against best practice. Instead, I recommend that you leave the input view of your first snap in your child pipeline open, which will allow the data payload to be passed to the child as if it is part of the parent pipeline - no formatting or parsing necessary.
Hope this helps!
PS - you did not attach your sample pipeline, so I interpreted as best I could. If you are having difficulty attaching the SLP file, you can just zip it and attach the zip file.
3 weeks ago
3 weeks ago
3 weeks ago
I'm happy that worked for you! And thank you for marking the solution- that helps close out the thread.