Type is a standard field on the object Account, and also apparently a reserved word in APEX, so how can I write/alter my SOQL query to include data from this field? I found documentation on creating aliases and aggregate expressions, but it didn't really answer my question.

I also need to base if/else statements later on in the trigger on this field, how do I force APEX to treat it like the field it is instead of a reserved word at that time?


  • 1
    Can you share your code ? Jan 26, 2015 at 15:46
  • Yes, please share your code. Select Type From Account executes fine for me.
    – BarCotter
    Jan 26, 2015 at 15:47
  • My query: List<Account> accounts = [select Id, Account_Domain__c, Type from Account where Account_Domain__C LIKE :wildCard]; I was just informed by a more seasoned dev on my team that although it's on the list of reserved words & highlighted in DEV Console to indicate that, presently writing it this way shouldn't effect anything. So I guess the real question is, what happens to the trigger when Salesforce decides to assign value to this word they've reserved? For now though it sounds like a work-around isn't needed, and I jumped the gun on reacting. Thank you for your responses!
    – LMBB
    Jan 26, 2015 at 16:07
  • For reference : Shows "Type" as reserved for future use: salesforce.com/us/developer/docs/apexcode/Content/…
    – LMBB
    Jan 26, 2015 at 16:09

1 Answer 1


The SOQL query will look like this:

SELECT Type FROM Account

So for example when you create and insert an account

Account newAcc = new Account();
newAcc.Name = 'Test';
newAcc.Type = 'WhatEverValue';
insert newAcc;

In your if statement you will have

if(newAcc.Type == 'Your Value'){
    //Code statement


   //Code statement

You must log in to answer this question.

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