• Akshay Agarwal 36
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi Experts,
  Pls help me to solve the below issue.I am trying to take a trailhead challenge and i have created the below class and it is working fine able to create the account ,but when i am checking the challenge completion i am getting the error.

public class AccountHandler {
      public static Object insertNewAccount(String strNames)
      {
          try
          {
          Account acct = new Account();
            acct.Name = strNames;
            acct.Phone = '(415)555-1212';
            acct.NumberOfEmployees = 100;
        insert acct;
        //ID acctID = acct.Id;
// Display this ID in the debug log
//System.debug('ID = ' + acctID);
              return acct;
          }
          catch(DmlException  ex)
          {
              System.debug('Got the Error:' +ex.getMessage());
              return null;
          }
      }

}

Challenge not yet complete in My Trailhead Playground 1
Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account.
Hello,

I am beginner in Salesforce and still in initial steps in understanding the concepts..i tried the below class and the output didnt come as expected 

public class mytest2 
{
    Public integer marks;
    Public string result;
        {
        if(marks >= 35 && marks <= 50)
        result = 'passed';
        else if (marks >= 51 && marks <= 70)
        result = 'B';
        else if (marks >= 71)
        result ='A';
        else 
        result = 'failed';
                {
                  system.debug('Your results:' + result);
                }
        }    
}

and executing it in anonymous window 

mytest2 c1 = new mytest2();
c1.marks = 55;
system.debug(c1);

Output was Your results:failed

which seems to be wrong ..not sure what went wrong here