global with sharing class OCM_Ctrl2 {
|
global Rental_Apply__c ra {get;set;}
|
global Repair__c rp {get;set;}
|
global Asset ast {get;set;}
|
|
global OCM_Ctrl2(){
|
ra = new Rental_Apply__c(photoType__c='');
|
rp = new Repair__c(photoType__c='');
|
ast = new Asset(photoType__c='');
|
string pid = ApexPages.currentPage().getParameters().get('pid') ;
|
string objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix(pid);
|
SObject s = Database.query('SELECT recordTypeId FROM ' + objectName + ' where id=\''+pid+'\'');
|
String recordTypeId = String.valueOf(s.get('recordTypeId'));
|
System.debug('objectName='+objectName+' recordTypeId='+recordTypeId);
|
if(objectName == 'Rental_Apply__c'){
|
ra.RecordTypeId = recordTypeId;
|
} else if(objectName == 'Repair__c'){
|
rp.RecordTypeId = recordTypeId;
|
} else if(objectName == 'Asset'){
|
ast.RecordTypeId = recordTypeId;
|
}
|
|
}
|
}
|