0

My question is similar to this one, however in my case, my Apex classes are Dynamic, auto-generated by an External Service that I created.

I started off by creating a Salesforce DX project. Next I created a scratch org based on the project's definition file. Then I opened up the scratch org and created an External Service and 2 companion Flows utilizing the External Service. After testing the Flows locally in my scratch org, I force:source:pull'ed what I assumed were all of the changes back into my project.

I then subsequently created another scratch org and attempted to force:source:push the code into the 2nd scratch org, with the intention of validating my changes. However, the force:source:push resulted in the following error:

"MY_FLOW_NAME (Variable) - "apexClass" is invalid. Provide the API name of an Apex class that includes an Apex data type supported in flows."

When looking at the source files that the sfdx CLI pulled into my project, I can see the External Service definition, however nowhere do I see the name of the Dynamic Apex classes created, so I'm not really sure how/where I would provide the API name.

There was a comment in the other question that I referenced that asked if the poster's package included permissions for the Apex class. In my case, I'm not seeing any specific permission settings related to those Dynamic Apex classes, so I'm wondering if that's the problem. In which case, I'm not sure what I would need to do to fix it.

I'm really scratching my head trying to figure out how to get past this blocker. Any help would be greatly appreciated.

2 Answers 2

0

I figured it out. Oddly, the error was related to the fact that I had recently added a Namespace to my project (by setting the value of the namespace property in sfdx-project.json to one I had registered).

To troubleshoot the error, I removed the Flows from my project and then tried to push the code to the new scratch org again. This time, it worked. However, when examining the Dynamic Apex Classes that were generated, they now had a Namespace Prefix that looked like this: ExternalService.MYNAMESPACE, which is what I would have expected. But when I went to open up one of the apex classes to see the code that was generated, I got the following error message:

Data Not Available The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.

It seems to me that Salesforce doesn't seem to like the use of Namespaces in conjunction with External Services (and/or with Dynamic Apex in general). Because as soon as I removed the namespace from my project and added my Flows back, I was able to push the code to the scratch org with no issues. Now to figure out if there's a way to get around this issue, because I would really like to be able to use a Namespace with my packages!

0

For working with a namespace the prefix for the file is ExternalService__{namespaceprefix}__{filename}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .