• Muthu_t
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi,

 

I am trying to add error message by using adderror method. But it is throwing an error like this.

 

Error:

A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:'System.FinalException: SObject row does not allow errors
Class.InTheMarketOpportunity.marketOpportunity: line 8, column 9External entry point', }

 

Code:

 

Am executing this code.

 

    global class InTheMarketOpportunity{    webservice static void marketOpportunity(String accountid,String solicitid,String state,String city){    Account a=new Account();         list<Opportunity> marketAccount= new List<Opportunity>();        marketAccount=[select Id,AccountId from Opportunity where In_The_Market__c =: accountId];        if(marketAccount.size()>0){        In_The_Market__c acc=[select Id from In_The_Market__c where Id =: accountId];        acc.addError('Already created');        }    system.debug(':::::HERE::::::'+accountId);
        }}