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
johncusackjrjohncusackjr 

Namespace Prefix for Custom Objects

Hi,

 

I have a Flex application working with Salesforce.com. Based on object name I am doing some calculations in Flex side.

 

Standard objects don't require namespace prefix (e.g. xyz__) when controlling, but custom objects require it. So when I try to make a decision based on object name I need to create this logic:

 

if(Account) { } else if(Opportunity) { } ... else if(xyz_MyCustomObject__c) { }

 

 

But to do this I need to know the xyz namespace prefix. If I hardcode it, it won't be useful for other customers that install my application. Because they'll be able to create their custom objects and my flex app will handle their needs just based on custom object name.

 

Is there any solution to retrieve namespace prefix dynamically or refer the custom object without namespace prefix?

 

Thanks,

John

A_SmithA_Smith
Are you building an app that will work with any custom objects the customer creates?
johncusackjrjohncusackjr
Yes. This is the exact case. My application will work on / control customer's custom objects. Do you know the solution? Thanks...
A_SmithA_Smith
Check out dynamic apex.  It's a way to get a list of the objects in a customer's org on the fly - complete with namespaces.  Then you don't have to hardcode all this.