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

getting this error "record id cannot be empty key", while inserting a Case using VF.
Hi All,
getting this error "record id cannot be empty key", while inserting a Case using VF.
I Have a created a VF page with StandardSetController means RecordSetVar="true". Standard Controller ="Case"
I have used in StandardSetController in Extensions Controller.
cas=(Case)controller.getRecord();
cas.RecordTypeID=rtID;
cas.OwnerID=UserInfo.getUserID();
and i have overrieded Save Method and below
public PageReference Save()
{
try{
// Case c=new Case();
c1=cas;
insert c1;
return New PageReference('/'+cas.id);
}
catch(Exception e){
ApexPages.addMessages(e);
}
return null;
}
while inserting a Case i am getting "record id cannot be empty key", error
In the ViewState, i found Case id is having 00000000000
Can anyone know about this, help me out.
Thanks
getting this error "record id cannot be empty key", while inserting a Case using VF.
I Have a created a VF page with StandardSetController means RecordSetVar="true". Standard Controller ="Case"
I have used in StandardSetController in Extensions Controller.
cas=(Case)controller.getRecord();
cas.RecordTypeID=rtID;
cas.OwnerID=UserInfo.getUserID();
and i have overrieded Save Method and below
public PageReference Save()
{
try{
// Case c=new Case();
c1=cas;
insert c1;
return New PageReference('/'+cas.id);
}
catch(Exception e){
ApexPages.addMessages(e);
}
return null;
}
while inserting a Case i am getting "record id cannot be empty key", error
In the ViewState, i found Case id is having 00000000000
Can anyone know about this, help me out.
Thanks
You have used incoorect contoller you should you StandardController in vf . StandardSetController is used to dislay list of records.
Below are the links to find difference between standard controller and standardsetcontroller.
http://salesforce.stackexchange.com/questions/48199/what-is-the-difference-between-list-controllers-and-set-controllers
controller.getRecord() method will return sObject that represents the changes to the selected records.
Case cas;
//get record type id by recordtype label
Id rtID=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('RecordType label').getRecordTypeId();
cas=(Case)controller.getRecord();
cas.RecordTypeID=rtID;
cas.OwnerID=UserInfo.getUserID();
public PageReference Save()
{
try{
if(cas!=null)
{
insert cas;
}
return New PageReference('/'+cas.id);
}
catch(Exception e){
ApexPages.addMessages(e);
}
return null;
}
Please let me know if it helps you.
Best Regards,
-Vivek