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

Get NameSpace Dynamicaly

i have uploaded my package successfully.

but when installing in onother org than some of my app's pages are not grtting perfect url with namespace so its giving "no page found. create new page." error.
so i need to update url with Namespace of my package.

so is there any way to do it.

its urgent ...

Axaykumar VaruAxaykumar Varu

you can get Namespace Prefix,by using following query


ApexClass cs = [SELECT NamespacePrefix FROM 'Apex class name  from package name'];

String namespace = cs.NamespacePrefix;


or you can retrieve namespace from all the classes,


List<ApexClass> cs = [SELECT NamespacePrefix FROM ApexClass];

String namespace = cs[0].NamespacePrefix;