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
Afrose AhamedAfrose Ahamed 

How to show number of records in Confirm prompt before action method on VF

Hi All,

This is just snippet of code that i want to acheive. My apologise if its not understandable im a beginner. I want show a prompt in that  i want show number of records counts from apex class before deleting action happened.Somehow  prompt is showing but Deleting records count is not showing. Please refer the below code and advise how can i acheive this. it will be a great help..

<apex:page sidebar="false" showHeader="false" controller="OldDataController" standardstylesheets="false">
    function changeComplete(){

 <apex:commandLink oncomplete="changeComplete();" onclick="if(!confirm('Do you want to proceed? {!numberOfRecDeleted}')) return false;"  action="{!DeloldRecords}" status="loadingStatus"  style="margin-left:4px;"><span class="glyphicon glyphicon-file"></span> Delete Records</apex:commandLink>
public with sharing class OldDataController {

public static Integer numberOfRecDeleted {get;set;}

public static void delController(List<Records__c> DelRecs){
list<String> DelRecsNames = new List<String>();
for(Records__c DelRec : DelRecs)
numberOfRecDeleted = DelRecsNames.size();
DMLManager.deleteAsuser([Select id from Records__c where id:DelRecsNames]);
System.debug('Number of Records Deleted'+numberOfRecDeleted);

User-added image


Afrose Ahamed M.G

PriyaPriya (Salesforce Developers) 
Hi Afrose,

You can take the reference fromt this code to insert the number of record in popup message :-

Kindly mark it as the best answer if it works for you.


Thanks & Regards,

Priya Ranjan