yesterday
Currently I am trying to map list items
Currently, when the entire list has no data, the output is generated in the following format:
However, if the list is completely empty, I donโt want the array to appear at all in the output payload. The list field should be entirely omitted, with no empty objects or placeholders included.
Is there a workaround to conditionally exclude this field from the output when no data is present?
yesterday
I've never found a simple solution for this problem, so I use a Ruby action with this code to recursively remove null/blank keys. Hopefully someone has a native or better way of doing this.
def deep_compact(obj)
case obj
when Hash
obj.each_with_object({}) do |(k, v), h|
cleaned = deep_compact(v)
h[k] = cleaned unless cleaned.nil? || cleaned == ""
end
when Array
obj.map { |v| deep_compact(v) }.reject { |v| v.nil? || v == "" }
else
obj
end
end
10 hours ago
Thank you, @gary1
For ease of explanation, I have shown CDM here however, the actual scenario deals with SAP RFC โ Send IDoc. CDM in this context refers to the SAP IDoc structure only and is used purely for representation. There is no downstream processing involved everything required must be handled entirely within the SAP step.
5 hours ago
I don't think you can solve this issue in the input of the SAP step. You need to pre-process the data to remove the empty objects from the array (using the Ruby I provided) and then map the output of the Ruby action into the input of SAP step.
I can't guarantee this will work for your exact situation, but it has worked for me in similar situations before.