0
votes

...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]

2
Have a look at salesforce.stackexchange.com/questions/49711/… and then implement via Muleidentigral

2 Answers

1
votes

See if there's describe support. describeLayout is primarily used if you need to recreate a SF page in a mobile app for example, won't tell you much about field types and will list only fields the end user can see, there can be more hidden in the background.

You could have some luck with REST API describe: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_describe.htm

Or metadata API: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_describesobjects_describesobjectresult.htm

I don't know what's available for you. I'd expect Mule connector to do it for you as part of some connection wizard, pull info about all queryable tables and after you pick one - about all fields you can see in it. Maybe you're overcomplicating something, you need a truly dynamic SELECT * equivalent, that would work when admin adds new fields without having to refresh the connection?

Metadata can also be queried, it's stored in tables like actual data. See if https://stackoverflow.com/a/60067076/313628 helps.

1
votes

...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.