Anonymous Apex does not recognize types when project namespace prefix is not used

Issue #1963 resolved
Attila Hajdrik created an issue

The package prefix and scratch org is ‘vz’ and in the Anonymous Apex window the editor does not recognize the types when the namespace prefix is not there.

See the lack of vz. from AddressMapper in the screenshot.

Comments (12)

  1. Scott Wells repo owner

    Yeah, this is actually a known/intentional behavior. Without going into the details, it has to do with IC2's support for developing in multiple namespaces in a single project/org, and also because you can switch connections in the Anonymous Apex tool window which could change the namespace context. So that's why it works this way now...

    Having said that, if the selected connection is used for only a single namespace in the project, it would make sense for the Anonymous Apex editor to be treated as if it were "inside" that namespace just as an Apex type source file behaves. I'll chew on that...

  2. Attila Hajdrik reporter

    Makes sense and I see the reasoning, and yes my use case is the last one you suggested and also for ISVs who are working usually in the same namespace it makes it easier as you can copy and paste code from files of the project without the need to add namespaces all over.

  3. Scott Wells repo owner

    Okay, I have a fix for this locally. It won't be included in tomorrow morning's build as I want more test time on it, but I don't think it should be an issue including it in next week's build.

  4. Aliaksandr Luferau

    @Scott Wells Hello. Please explain if this feature possible to disable (at least on the SOQL Query editor) - I want that when i start typing then api names of the custom object and custom fields will be autocompleted with package prefix, as it was previously - for now i need to add prefix manually to each of them.

    Issue probably caused by current feature. Good to have possibility to enable/disable for this feature

  5. Scott Wells repo owner

    Hi, Aliaksandr. I'm laughing a bit because by now I should have learned that whenever I change a behavior (where both before and after are valid, of course), someone is likely already expecting the previous behavior, so the change should be put behind a configuration option.

    No problem. I'll make this configurable, likely for the next build. Sorry for the unexpected and undesired change!

  6. Aliaksandr Luferau

    Thanks. This is useful when you need to share your soql or code snippet with other people who use the developer console or similar tools, so the api names must be with prefixes.

  7. Scott Wells repo owner

    Okay, I made this configurable for both the Anonymous Apex and SOQL Query tool windows, e.g.:

    Issue_1963_Config.png

    The new option, Use default namespace, defaults to true for both scripting tools, but when disabled things behave as they did before this change.

    This will be included in the next build, likely released next Thursday.

  8. Scott Wells repo owner

    My pleasure! Sorry for temporarily nuking your workflow. Thanks for bringing it to my attention.

  9. Log in to comment