Search code examples
salesforceanypoint-studiomulesoft

How to gather complete object schema with Mulesoft Salesforce connector (Mule 4)


...I'm using the Mule Salesforce connector (for Mule Runtime 4.4.2) in Anypoint Studio (7.4.2).

The Salesforce query language does not allow the * operator to gather all keys from an object, so I'm looking for another means to retrieve a sample object and create a model record that I could use for updates and creation.

Using the Task object (documented here: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_task.htm) as an example, I find that the describeLayout() and retrieve() methods look promising.

However, when I try to invoke retrieve(), I'm required to submit a list of fields to retrieve.

I don't see the describeLayout() method exposed in the connector, so I haven't seen what it returns.

Have I missed a general purpose approach to allow me to gather every field from a sample object?

[edited for clarity]


Solution

  • ...so it turns out that the Mule 4 Salesforce connector does support describe SObject.

    To the Anypoint Studio developer, it shows up like this:

    Describe SObject connector

    The XML definition offers little further insight.

    Update: After further investigation, it turns out that an additional operation needs to be applied using Dataweave to get a simple list of fields. After you have the SObject structure in payload, you will:

    payload.fields.*name
    

    This yields an array with the field names.