10

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 Answers 3

19

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.

3
  • Thank you mate! :) It is true, but I should have done additional step - add my namespace prefix to the custom objects name 8-() Mar 20, 2019 at 8:16
  • Thanks, this really helped me...
    – Srujan
    Dec 9, 2019 at 9:25
  • thank you .. was driving me nuts!
    – Etienne
    May 7 at 19:55
4

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

1

Sometimes "Auto-completion" still don't work even after refresh object definitions.

It is because of the Java Home Path not configured with the VS Code.

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.