1

I have enabled namespace in my dev org.

Namespace name - LightningMyth.

When I write the following query in any class/trigger,

List<Account> acc=[SELECT ID FROM ACCOUNT limit 1];

I get the error :

Illegal assignment from List<Account> to List<LightningMyth.Account>

but the same query works fine in workbench and QueryEditor.

When I changed the query to

List<LightningMyth.Account> acc=[select id from LightningMyth.Account limit 1];

I get this error -

Compile Error: First SObject of the FROM statement must be a valid SObject type.

I get this issue after enabling namespace and this issue is only with Account object, the SOQL with other standard and custom objects works just fine. Any help is appreciated!

3 Answers 3

2

In your organization, somewhere you might have created a class named "Account". That's why the compiler is not able to understand that whether it is standard Object Account or the class created by you. Please rename your class, it will work.

1
  • Thanks Devendra! I actually had a class named Account. I renamed that class and it all worked fine. Commented Jun 22, 2016 at 13:42
0

Namespaceprefix does not append with Standard objects and fields or components.They only get appended to custom objects and fields or components which are present in the org.

So there is no need to append namespaceprefix with your query on account object.

As far as your first query is concerned that looks fine.

-1

Try prefixing references to the Account with Schema. When you use Account as your class name, it is really shorthand for Schema.Account. Using the fully qualified class name will avoid conflict.

For example:

List<Schema.Account> acc = [/*query*/];
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .