You need to sign in to do that
Don't have an account?
Geetu
Apex test class - Recordtype
can somebody pls help me to write test class for below code in apex class
//Get RecordTypes name from Account Object
@AuraEnabled
public static string findRecordTypes(string objName){
string returnString='';
string queryString='Select id,name from RecordType where sobjectType =: objName
List<sobject> recordList= Database.query(queryString);
List<RecordTypeWrapper> wrapperList=new List<RecordTypeWrapper>();
for(sobject sb : recordList) {
RecordTypeWrapper rw=new RecordTypeWrapper();
rw.recordTypeLabel=string.valueof(sb.get('name'));
rw.recordTypeId=string.valueof(sb.get('id'));
wrapperList.add(rw);
}
returnString= JSON.serialize(wrapperList);
return returnString;
}
//Get RecordTypes name from Account Object
@AuraEnabled
public static string findRecordTypes(string objName){
string returnString='';
string queryString='Select id,name from RecordType where sobjectType =: objName
List<sobject> recordList= Database.query(queryString);
List<RecordTypeWrapper> wrapperList=new List<RecordTypeWrapper>();
for(sobject sb : recordList) {
RecordTypeWrapper rw=new RecordTypeWrapper();
rw.recordTypeLabel=string.valueof(sb.get('name'));
rw.recordTypeId=string.valueof(sb.get('id'));
wrapperList.add(rw);
}
returnString= JSON.serialize(wrapperList);
return returnString;
}
Raj Vakati
This will work
Geetu
thanks Raj...and how can i insert a test record for Record type in above test class, so my apex class requirement is to - find record type and then insert a account.
Raj Vakati
Record type you can't insert and you can query
Raj Vakati
Geetu
ok Raj, i have been asked to create a test record first.. can u explain why we cannot create it
Raj Vakati
Record types are avaible in test class with out insert and you need to insert the same record type with same name it will fail
Geetu
thanks Raj. Can i please have your email address. i have few issues in writing my test class. Would be great if you can help me