function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anoop RbAnoop Rb 

How to delete records without using param in visualforce page?

Can any one help me i have displayed records in visualforce pagehere i have delete each record without using param.
Ankit AroraAnkit Arora
See if you are using a controller with the visualforce page then you can use wrapper classes. In wrapper class you can add a checkbox with the records, and each time a checkbox is checked and clicked for deletion then you can do this via wrapper class and no need to pass the Param from VFP.
Anoop RbAnoop Rb
Here I need to delete records without using param and wrapper class. Is there any way..?
Ankit AroraAnkit Arora
If you are using standard controller then it can be done on the page itself, otherwise not able to understand why you don't want to use the param as in any approach like actionfunction or JSRemoting or any other I think you've to pass the param.
Dushyant SonwarDushyant Sonwar
Hi Anoop,
use this
<script src="/soap/ajax/20.0/connection.js" type="text/javascript"></script>
<script>
function delrec(conid){
          sforce.connection.sessionId = "{!$Api.Session_ID}";
          var contact = new sforce.SObject("Contact");
          contact.Id = conid;
          
          var delResult = sforce.connection.deleteIds([contact.Id]);
          if (delResult[0].getBoolean("success")) {
            alert("account with id " + delResult[0].id + " deleted");
          }
          else{
            alert("failed to delete account " + delResult[0]);
          }
      } 
</script>

pass the id which record you want to delete for Contact Or Any other object Create that Sobject first and use deleteids to delete that particular record.
Ankit AroraAnkit Arora
Am still keem to know why he don't want to send the ID in param, as by this also he is sending the ID to function which is equivalent to sending the ID to action function. Also it will consume an API hit.