Function to split an array of notifications

This is a salesforce outbound SOAP message. Which could work perfectly with n8n if it was possible to split each notification from the file. The example below has 2 notifications in - but there could be up to 100.

Would a n8n Function node be able to do this?

Any help would be very much appreciated!

[
  {
    "headers": {
      "host": "sgb.app.n8n.cloud",
      "x-request-id": "9bd9a30fc0fb38ac49ddc010273c8f05",
      "x-real-ip": "10.40.17.79",
      "x-forwarded-for": "10.40.17.79",
      "x-forwarded-host": "xxx.app.n8n.cloud",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-scheme": "https",
      "x-scheme": "https",
      "content-length": "3955",
      "accept-encoding": "gzip",
      "content-type": "text/xml; charset=utf-8",
      "soapaction": "\"\"",
      "user-agent": "Jakarta Commons-HttpClient/3.1"
    },
    "params": {},
    "query": {},
    "body": {
      "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": "00D3z000000gWE1EAI",
            "actionid": "04k3z0000008RWqAAM",
            "sessionid": "00D3z000000glE1!AQMAQCcQ4x0rOptX7.tZHVqW2_.N05z4DK8J40nCboNyD4Nu9qlKntiiconBG5vXwzbkGfxHin9zUJaQ3yNR6Wb8aqKEQ9Ek",
            "enterpriseurl": "https://customer.my.salesforce.com/services/Soap/c/54.0/00D3z000000gWE1",
            "partnerurl": "https://customer.my.salesforce.com/services/Soap/u/54.0/00D3z000000gWE1",
            "notification": [
              {
                "id": "04l3z00001gGsxgWAC",
                "sobject": {
                  "$": {
                    "xsi:type": "sf:Contact",
                    "xmlns:sf": "urn:sobject.enterprise.soap.sforce.com"
                  },
                  "sf:id": "0033z0W002sB30rAAC",
                  "sf:email": "[email protected]",
                  "sf:firstname": "Mike",
                  "sf:job_title__c": "Sales Manager",
                  "sf:lastname": "Jones",
                  "sf:mobilephone": "+447455550823"
                }
              },
              {
                "id": "04l3z00001gWsxeAAC",
                "sobject": {
                  "$": {
                    "xsi:type": "sf:Contact",
                    "xmlns:sf": "urn:sobject.enterprise.soap.sforce.com"
                  },
                  "sf:id": "0033z00002pcQWgAAE",
                  "sf:email": "[email protected]",
                  "sf:firstname": "Stacey",
                  "sf:job_title__c": "Sales Assistant",
                  "sf:lastname": "Smith",
                  "sf:mobilephone": "07735559912"
                }
              }
            ]
          }
        }
      }
    }
  }
]

Hi @simon_pc, thanks for sharing your example data. Looks like the notification data itself lives under body["soapenv:envelope"]["soapenv:body"]["notifications"]["notification"]. To split out your notifications, you could use the Item Lists node and specify the above field to split out:

Afterwards, you’ll have two separate items, one for each notification:

1 Like

THANK YOU SO MUCH @MutedJam :grinning: :grinning: :grinning:

1 Like

You are most welcome! Enjoy your automation journey and please do give us a shout in case you get stuck somewhere!