I have an problem with my vf page,whenever I delete the record from my list ,record will deleted but I unable to return my list.

public PageReference deleteRecord()
   ID rid = ApexPages.currentPage().getParameters().get('ruleID');
   PageReference deletepage = new PageReference ('/'+rid+'/e?retURL=/apex/performanceReviewoutput');

   String runQuery='select  Name from Performance_Review_Input__c where id= \''+rid+'\''; 
   List<Performance_Review_Input__c> listdeDatabase.Query(runQuery);

   delete listdel;
   return deletepage;

Why are you trying to return to the edit page of a deleted record? What are you trying to accomplish?

Two things I notice about your code, you are vulnerable to SOQL injection and you don't even need to perform a query.

If you remove your query, you actually remove the injection vulnerability. Before performing the delete, however, I would do a little checking on the Id first.

if (ruleId instanceOf Id && Id.valueOf(ruleId).getSObjectType() == Performance_Review_Input__c.sObjectType)
    Performance_Review_Input__c recordToDelete = new Performance_Review_Input__c(Id=ruleId);
    delete recordToDelete;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.