This is the error i am getting in webservice

Hello Guys,

I am learning Webservice but I am getting this error ::Error: Compile Error: Argument type of global method must also be global: Account at line 2 column 26

I am following the salesforce documentation Salesforce Apex Document, If they have given it in document it means code is proper. Is there any problem with my Developer Edition ? I even tried deactivating the triggers but it's not working .

  • 5
    Do you have a class in your org called 'Account' incidentally? Commented Jan 15, 2014 at 15:53
  • Yes... I have....
    – user40138
    Commented Jan 15, 2014 at 15:56
  • Once I delete the Account Class I able to save the webservice class..Thanks for pointing out.. By the way why I was getting that Error ? any clue...
    – user40138
    Commented Jan 15, 2014 at 16:00
  • 2
    This is called shadowing. Your type was not fully qualified and the compiler sees namespace.Account (class type) instead of Schema.Account (sobject type), as you created a class with that name. Commented Jan 15, 2014 at 19:27
  • @user320 your comment solved my problem but i will select -sfdcfox- answer as Accepted answer
    – user40138
    Commented Feb 21, 2014 at 15:15

1 Answer 1


You have a class named Account. Unless that class is global, it would not be accessible to the Web Service method.

public class Account { /* Cannot be a parameter in a web service */ }

global class Account { /* Can be a parameter in a web service */ }

If you specify a class name that mimics a system object (e.g. Account, Contact), then you must explicitly use the Schema namespace to reference the standard object. The following code will work regardless of the presence of an Account class:

global class MyWebService {
    webservice static Id makeContact(String lastName, Schema.Account a) {
        Contact c = new Contact(LastName='Weissman', AccountId=a.Id);
        insert c;
        return c.Id;
  • when you get a sec @sfdcfox can you make some trivial edit to this answer to unlock votes? rgds Commented Jan 15, 2014 at 23:49
  • @user320 As you wish!
    – sfdcfox
    Commented Jan 15, 2014 at 23:59

You must log in to answer this question.

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