3

I am trying out the VS Code and wondering if it could be possible to display custom object fields while typing an apex code. At the moment the fields are not displayed:

enter image description here

But when I take some standard object like Account they are already there:

enter image description here

What is wrong?

3

Autocomplete depends on the metadata cache. To fix this, go to View > Command Palette (Ctrl-Shift-P), and type in "sobject". You should see a command "SFDX: Refresh sobject definitions." After that command runs, you should get autocomplete for all custom objects and fields.

  • Thank you mate! :) It is true, but I should have done additional step - add my namespace prefix to the custom objects name 8-() – Sergej Utko Mar 20 at 8:16
0

I will answer my own question because I have found the problem (I think).

The autocomplete for custom object depends on the metadata definition, like @sfdcfox said. After updating the sobjects it did not work again. The tricky part is: my org has a namespace, so I should explicitly specify the namespace prefix to the custom object name in the apex code.

It is not necessary to do this in order for the code to work, but it seems to be necessary for the vs code to make the autocompletion work :(

So with a namespace prefix it works, without it not:

enter image description here

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.