I want to create a new record on click of button by giving its record type.
please find the code below
public pageReference Test()
{
RecordType rt =[SELECT ID, name FROM RecordType WHERE SObjectType = 'App__c' and name='Test_Contact'];
this.ap.Client__c = account.Id;
this.ap.RecordTypeId =rt.Id;
insert (this.ap);
pageReference pageRef = new pageReference('/oaoa/TestForm');
pageRef.setRedirect(true);
pageRef.getParameters().put('id',ap.id);
return pageRef;
}
I am getting error as List has no rows for assignment to SObject Rt is not returning any value