• Kevan
  • NEWBIE
  • 0 Points
  • Member since 2013

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

In a test class, I am trying to create an opportunity of a specified record type. 

 

   //create opportunity record
        String opportunityName= 'xxxx';
            Opportunity o = new Opportunity(
            AccountId=a.Id, 
            Name=opportunityName, 
            StageName='Prospecting', 
            CloseDate=Date.today(),
            Opportunity_Type__c='New',
            LeadSource='xxx',
            RecordTypeId= [Select Id From RecordType Where Name = 'xxx' and SobjectType= 'Opportunity'].Id);
            
        insert o;
        system.debug(o.RecordType.Name);
        

 

However this returns- null in the debug statement. I'm sure i'm overlooking something simple. Any help?

  • December 03, 2013
  • Like
  • 0