You need to sign in to do that
Don't have an account?
dev rana 10
Problem in delete the record through controller
Hello Every on i m trying to delete record through controller but not able to do.
This is my vf page
This is my Controller
This is my vf page
<apex:page sidebar="false" showHeader="false" controller="customerEditRemoveController"> <apex:form id="form" > <apex:pageBlock title="Customer Detail"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockTable value="{!Custreg}" var="row"> <apex:column > <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | <a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column value="{!row.Name__c}"/> <apex:column value="{!row.Last_Name__c}"/> <apex:column value="{!row.Mobile__c}"/> <apex:column value="{!row.Email__c}"/> <apex:column value="{!row.Country__c}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:actionFunction action="{!deletecustomer}" name="deletecustomer" reRender="form" > <apex:param name="RegCustId" value="" assignTo="{!SelectedRegCustId}"/> </apex:actionFunction> </apex:form> </apex:page>
This is my Controller
public class customerEditRemoveController { public List<devrana__RegCustomer__c> Custreg { get; set; } //used to get a hold of the account record selected for deletion public string SelectedRegCustId { get; set; } public customerEditRemoveController() { //load account data into our DataTable LoadData(); } private void LoadData() { Custreg = [Select id, devrana__Address__c,devrana__Adults__c,devrana__Arival_Time__c,devrana__child__c,devrana__Country__c,devrana__Departure_time__c,devrana__Email__c,devrana__Last_Name__c,devrana__Mobile__c,devrana__Name__c,devrana__Reservation_Type__c,devrana__Rooms__c from devrana__RegCustomer__c limit 20]; } public void deletecustomer(){ if (SelectedRegCustId == null) { return; } devrana__RegCustomer__c tobeDeleted = null; for(devrana__RegCustomer__c rec : Custreg) if (rec.Id == SelectedRegCustId) { tobeDeleted = rec; break; } //if account record found delete it if (tobeDeleted != null) { Delete tobeDeleted; } //refresh the data LoadData(); } }
<a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
to
<a href="javascript:if (window.confirm('Are you sure?')) deletecustomer('{!row.Id}');" style="font-weight:bold">Del</a>
as the name of Action Function is "deletecustomer".
Hope this helps you!
Best Regards
Veenesh
you need to match function in javascript and target name.
you can either: or
cheers!
FearNone as per your Sugation my problem is solve.
Kindly mark the solution as solved and close the thread.
Veenesh