Concatenate Items with different path

Describe the problem/error/question

Hello everyone, I am receiving a response from a webhook, that can be different every times
Example 1:

soapenv:envelope
$
xmlns:soapenv:http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd:http://www.w3.org/2001/XMLSchema
xmlns:xsi:http://www.w3.org/2001/XMLSchema-instance
soapenv:body
notifications
$
xmlns:http://soap.sforce.com/2005/09/outbound
organizationid:00D1a5012312300000EueFEAS
actionid:04k4R00das0000123123H57lQAC
sessionid
$
xsi:nil:true
enterpriseurl:https://te.my.salesforce.com/services/Soap/c/58.0/dasdasd
partnerurl:https://test.my.salesforce.com/services/Soap/u/58.0/dasd
notification
0
id:04lUR00012312312001Q6u2YAC
sobject
$
xsi:type:sf:Lead
xmlns:sf:urn:sobject.enterprise.soap.sforce.com
sf:id:00QUR0000028mSw2AI
sf:ava__avaai_action_required__c:false
sf:ava__avaai_further_action__c:false
sf:ava__avaai_hot_lead__c:false
etc...

Example 2:

soapenv:envelope
$
xmlns:soapenv:http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd:http://www.w3.org/2001/XMLSchema
xmlns:xsi:http://www.w3.org/2001/XMLSchema-instance
soapenv:body
notifications
$
xmlns:http://soap.sforce.com/2005/09/outbound
organizationid:00D15012300000EueFEAS
actionid:04k4R0001231000H57lQAC
sessionid
$
xsi:nil:true
enterpriseurl:https://test.my.salesforce.com/services/Soap/c/58.0/00D15000000EueF
partnerurl:https://test.my.salesforce.com/services/Soap/u/58.0/00D15000000EueF
notification
id:04lUR000001Q8MLYA0
sobject
$
xsi:type:sf:Lead
xmlns:sf:urn:sobject.enterprise.soap.sforce.com
sf:id:00QUR0000028fpe2AA
sf:ava__avaai_action_required__c:false
sf:ava__avaai_further_action__c:false
sf:ava__avaai_hot_lead__c:false
sf:ava__avaai_lead_at_risk__c:false
sf:ava__avaai_sms_opt_out__c:false
etc...

So as you can see the difference is that sometimes the item “notification” contain an array and sometimes no

What is the error message (if any)?

The error is, how to handle this:
I am using a “Item List” Operation “concatenate items” aggregate “individual fields” for obtain the “SF:ID” value
With the “example 2” this is working:
body.soapenv:envelope.soapenv:body.notifications.notification.sobject.sf:id
But not with the “example 1”,
Is there an expression that allow me to cover both scenario?
Smtg like this:
{{$json[“body”][“soapenv:envelope”][“soapenv:body”][“notifications”][“notification”].sobject[“$”][“sf:id”] || $json.body[‘soapenv:envelope’][‘soapenv:body’].notifications.notification[0].sobject[“$”][“sf:id”]}}

Please share your workflow

My tries:
I’ve tried this expression but return me “undefined”
$json.body[‘soapenv:envelope’][‘soapenv:body’].notifications.notification[0].sobject[“$”][“sf:id”]

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.234.1
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): self-hosted
  • Operating system:

@Gabriele_Bracciali , I believe this data comes from Salesforce. Indeed, this is a very weird decision on their part. I handle it this way:

1 Like