3

While developing managed packages with DX I constantly run into the following problem:

  1. My developers use DX scratch orgs and the code uses the namespace we also latter use in the packaging org.
  2. My tester don't want to use scratch orgs for testing, so we deploy our code (by done feature) using metadata convert into a regular developer org (without namespace).
  3. We constantely forget to remove the namespaces from Aura component markup and JS and therefore get "Doesn't work" bug tickets.

Is there a better way to test (always create a Beta package) or is there a safe DX CLI command to remove namespaces?

  • 2
    For point #3, consider pulling the namespace dynamically in Apex so that you never run into hardcoding namespaces. This one liner works for me: public static final String CURRENT_NAMESPACE = MyAuraController.class.getName().split('\\.')[0]; – Brian Miller Apr 30 '19 at 9:33
  • How would that help with namespaces in component markup or JS files. Often records are passed around and field need to be retrieved correctly. I don’t know of any way to do that differently. – Robert Sösemann Apr 30 '19 at 20:26
  • 1
    I normally wrap sObjects in message classes to avoid just this problem. – Sebastian Kessel Apr 30 '19 at 20:28
  • Question: Why don't the testers want to use SFDX? why is it different for them? – Sebastian Kessel Apr 30 '19 at 20:29
  • 1
    If they know how to goto test.salesforce.com then I fail to see what is different. Give them username and password as it all works the same. Guess I am a bit confused. They do not need to use the cli. – Eric May 1 '19 at 6:29
3

There is no magic scripts available to strip of the namespace from the aura components.

I usually instruct developers to not use the namespace in code and work towards making components completely namespace independent .

Even if they have to hard code namespace do not use it everywhere. Just have it in common place where one could change it later easily .

One way to allow testing in sandbox with namepsaced code is to create a BETA package and install or even release a package if uninstalling Everytime is pain and has lot of config (version number will go up but that's fine does not hurt much)

| improve this answer | |
  • Beta packages are a no go because you have to uninstall them. Released packages are not made for unready states. So the only option is to get rid of namespaces in aura cmp and js and I don’t get how you do that’s. – Robert Sösemann Apr 30 '19 at 20:33
  • 1
    By using wrapper apex class for every sobject and avoiding use of __c variables altogether on markup . – Mohith Shrivastava Apr 30 '19 at 20:35
  • 2
    Also what do you mean by release packages are not made for unready states ? Is there a limit on no of versions you can have etc etc ? No right .just keep incremeting by patch no (major.minor.patch) and when ready create a package with major.minor – Mohith Shrivastava Apr 30 '19 at 20:36
  • Ok, you are right. But it feels somewhat bad to create a release package just to deploy my implemented story to a tester. But if that is the recommended way I just have to unlearn this. – Robert Sösemann Apr 30 '19 at 20:44
  • 2
    If it is per story then I think it will be too much to generate a package but if it is for a every two weeks it makes sense to just test the package. I would also push the tester on why he needs something in sandbox to test ? Every release testing or qa with bunch of stories makes sense .I would rather then use sandboxes for my dev ops process and build than fancy scratch orgs in this scenario. – Mohith Shrivastava Apr 30 '19 at 20:47

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.