You need to sign in to do that
Don't have an account?
Using apex to load detail view, OR create new record if none exists, for custom object data?
Hi all,
I think this is simple, but can't quite figure it out. Here's the use case:
A teacher has links to lesson plans (an object), 1-10, each residing in a different area of the page. Each lesson plan link sends the following to a new page:
Curriculum ID (Lesson_Plans lookup relation), Contact (owner) and number (1-10, since each renders a different template).
I'm trying to build a controller extension so that Lessons either loads the right detail view (pre-populated with the right information, if it exists) OR creates a new record with the information in the URL string, e.g., curriculum ID, contact owner and lesson number.
Any ideas / suggestions on how to make this happen?
Thanks!
--Dave
Public detailObject__c fobjDetail{
get{
if(fobjDetail == null){
detailObject__c fobjDetail = new detailObject__c();
List<detailObject__c> flstDetailObject = new List<detailObject__c>([select id from detailObject__c where pid__c = : ApexPages.currentPage().getParameters().get('pid')]);
if(flstDetailObject.size() > 0)
fobjDetail = flstDetailObject[0];
else{
insert fobjDetail;
}
}
return fobjDetail;
}
set{
fobjDetail = value;
}
}