3

So I have been working on my project for 2 months. Now we are finally ready to start the process whereby we will bundle it up as a managed package and then release it into the Salesforce App Store.

I've read that I need to get a namespace. I am curious how I add this in now?

If I look here:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespaces_creating.htm

I see some instructions for those of us who have a Developer edition. But I also see this text:

This button doesn’t appear if you’ve already configured your developer settings.

And I can not find that button.

Where do I look?

Also, do I have to change my code to use the namespace prefix everywhere? For instance, I have some controllers that use other utility code, like this:

So I have been working on my project for 2 months. Now we are finally ready to start the process whereby we will bundle it up as a managed package and then release it into the Salesforce App Store.

I've read that I need to get a namespace. I am curious how I add this in now?

If I look here:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespaces_creating.htm

I see some instructions for those of us who have a Developer edition. But I also see this text:

This button doesn’t appear if you’ve already configured your developer settings.

And I can not find that button.

Where do I look?

Also, do I have to change my code to use the namespace prefix everywhere? For instance, I have some controllers that use other utility code, like this:

    public class HeddySearchResultController {

    public String baseUrl { get; set; }
    public Search__c currentSearch { get; set; }
    public List<Map<String, String>> currentResults { get; set; }
    public HeddySession__c ps  { get; set; }


    class HeddyAccessException extends Exception {}


    public HeddySearchResultController() {
        // baseUrl is used by the Javascript in the VisualForce page
        String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();

        Id id = ApexPages.currentPage().getParameters().get('id');
        currentSearch = (id == null) ? new Search__c() : [SELECT Name FROM Search__c WHERE Id = :id];

    ps = HeddySessionModel.findCurrentSession();
   }

So if I get the namespace "Heddy" do I need to change this:

    ps = HeddySessionModel.findCurrentSession();

to this:

    ps = Heddy__HeddySessionModel.findCurrentSession();
3

Lightning components (Same as Managed Package)

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespaces_creating.htm

Create a namespace for your organization by registering a namespace prefix. If you’re not creating managed packages for distribution then registering a namespace prefix isn’t required, but it’s a best practice for all but the smallest organizations.

Managed Package

You need to create a package and then you can pick your namespace:

Setup -> Create -> Packages

Then under Developer Settings click "Edit" and follow instructions:

enter image description here

https://help.salesforce.com/articleView?id=creating_packages.htm&language=en_US&type=0

As for changing your code, when you package it references to fields and other metadata will have the namespace appended. However it is best practice to update your references in your code to use the namespace.

in your example you would change your code to this:

ps = Heddy.HeddySessionModel.findCurrentSession();
  • Classes use the ns.
  • Fields and SObjects use ns__
  • In this case, the difference between a class and an object is whether I've instantiated the class as an object? What would that look like for an object? Or do you mean sObject? – LRK9 Nov 11 '16 at 22:36
  • @LRK9 - SObject (dang autocorrect) – Eric Nov 11 '16 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.