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

very urgent issue.....
Hi,
I want to add error for save functionallity
so can any one help on this..
public void saveRecord(){
for(sObject obje : ssc.getRecords())
{
if(obje.get('WSR_Product__c')!=NULL)
{
try{
upsert obje;
system.debug('!!!!!!!!!!!!!!!!!!!' +obje);
}
catch(Exception e)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Object API name is invalid')) ;
}
}
}
//Make ssc variable null and execute get method
ssc = null;
getRecords();
}
Hi,
Try the below code snippet as reference:
public void saveRecord()
{
for(sObject obje : ssc.getRecords())
{
if(obje.get('WSR_Product__c')!=NULL)
{
try{
//or you can add error for the record
//obje.adderror('record name can't be null');
upsert obje;
system.debug('!!!!!!!!!!!!!!!!!!!' +obje);
}
catch(Exception e)
{
ApexPages.Message ErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Object API name is invalid');
ApexPages.addMessage(ErrMsg );
}
}
}
//Make ssc variable null and execute get method
ssc = null;
getRecords();
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
now also no giving any error message.
Hi Geetha,
TO get the custom error message your code has to reach in catch block. In case fif it does reach and you are still not able to see the error message than check whether you have a apex:pagamessages component iin you page. Add if you do not have it.
Let me know f you still face isssue.