function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jStarkjStark 

Using Remote Actions in a managed package

Good morning,

 

We've been developing an application that we have recently turned into a managed package. The addition of having a namespace has caused a few headaches. Throughout the application, we are using both the Ajax Toolkit as well as Remote Actions. Now the toolkit supports:

sforce.connection.defaultNamespace = 'TestApp';

 We ran across that by looking at both the documentation and the actual connection.js code. Now we have the issue with Remote Actions to clean up yet. What's happening is that as an example, we're returning some SObjects back, such as an array of custom objects. Then we are accessing fields like:

myObject.Sequence__c
myObject.OtherObject__r.Temp__c

 The issue here is that this code no longer works, since the namespace is proliferated through the results. The Ajax Toolkit does not put the namespace in the results.

 

Is there a way to use Remote Actions in a namespace-agnostic manner? Otherwise, how do we continue to develop in separate orgs with a team of developers that all deploy to 1 org for testing, and then move that to the org for building the package?

 

Thank you,

Jed

jStarkjStark

Here is some more information we've uncovered. The Remote Action calls are being successfully made from the Javascript to the server. For our Apex classes, we have a wrapper class that contains all of the Remote Actions. This interface then just calls methods from other classes that do all of the work. In these inner classes, if we make any SOQL queries that include custom objects/fields, the result has the namespaces with them. This is still while in the inner Apex class. When we try to parse through some of these results before sending the response back to the client, our parsing now fails due to the namespaces being applied. It seems like the call to the remote action isn't signaling the Apex code that: "I need to call this method, AND I'm in the same package so please don't send the namespace prefix along".

 

Another issue is with a SOSL FIND. We are trying to FIND across some custom objects and custom fields, and this does NOT work unless we explicitly add the namespace prefix on each item in the FIND. This also originates from a Remote Action call.

 

Thanks,

Jed