You need to sign in to do that
Don't have an account?

Record Type
Hi all does anyone know how i do a comparison on a record type name?
My test method is failing because this bit is never true:
if(opportunity.RecordType.Name == 'MDS')
and when i look in the debug log is if i do
system.debug('opportunity.RecordType.Name = ' + opportunity.RecordType.Name);
then all i see is null, but my test opportunit has a recored type, this is how i set the opp up:
opportunity3 = new Opportunity(Name = 'Test3', AccountId = account.Id, StageName = 'Final Contract Issued', Probability = 95, CloseDate = Date.today(), MCS_Commercials_Approved__c = true, HLD_created__c = 'HLD signed off', RecordTypeId = [select id, DeveloperName, Name from RecordType where Name = 'MDS' and sObjecttype = 'Opportunity' limit 1].id);
This is driving me crazy, Thanks All
recordtype rt = [select id, DeveloperName, Name from RecordType where Name = 'MDS' and sObjecttype = 'Opportunity' limit 1];
now use rt
opportunity3 = new Opportunity(_________ RecordTypeId = rt.id);
i hope it works
All Answers
try using ID of that record type
RecordtypeId
recordtype rt = [select id, DeveloperName, Name from RecordType where Name = 'MDS' and sObjecttype = 'Opportunity' limit 1];
now use rt
opportunity3 = new Opportunity(_________ RecordTypeId = rt.id);
i hope it works
Yeah thanks guys thats got it, i just needed to use the id rather than trying to use a string.