-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
1Questions
-
5Replies
Method Void Error on Custom object
Hey everyone, Im fairly new to APEX and need some guidance through this simple error. The error i receive is the Method void DeleteContact() is referenced by VisualForce page(cls) in salesforce.com. Remove the usage and try again.
This is pointing to the void DeleteInventory in the controller, so I am not sure what this error is exactly pointing.
cls page
here is the controller
This is pointing to the void DeleteInventory in the controller, so I am not sure what this error is exactly pointing.
cls page
<apex:page controller="clsController" sidebar="true" showheader="false" showChat="true" > <html> <head> <title></title> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet" media="screen"/> <style> body { padding-top: 60px; } </style> </head> <body> <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">Computer Inventory</a> <div class="nav-collapse collapse"> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#else">Contact</a></li> </ul> </div> </div> </div> </div> <div class="container"> <apex:form id="form"> <apex:image value="{!$Resource.LogoAbel}" width="30%" /> <apex:pageBlock title="Computer Inventory"> <apex:pageMessages > </apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlock > <apex:panelgrid columns="2"> <apex:selectList value="{!selectedField }" size="1"> <apex:selectOption itemValue="Employee_Name__c" itemLabel="EmployeeName"/> <apex:selectOption itemValue="ASI_Solutions_Inventory_Number__c" itemLabel="ASI Solutions Inventory Number"/> <apex:selectOption itemValue="Location__c" itemLabel="Location"/> <apex:selectOption itemValue="Make__c" itemLabel="Make"/> <apex:selectOption itemValue="Model__c" itemLabel="Model"/> <apex:selectOption itemValue="Purchase_Date__c" itemLabel="Purchase Date"/> <apex:selectOption itemValue="Serial_Number__c" itemLabel="Serial Number"/> <apex:selectOption itemValue="Warranty__c" itemLabel="Warranty"/> <apex:selectOption itemValue="Vendor__c" itemLabel="Vendor"/> </apex:selectList> <apex:commandButton value="Click Here to Sort" action="{!sortMethod}" reRender="pgblcktbl"/> </apex:panelgrid> </apex:pageBlock> <apex:pageBlock > <apex:pageblocktable value="{!inventories}" var="rec" id="pgblcktbl" > <apex:column > <apex:outputLink title="" value="/{!rec.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | <a href="javascript:if (window.confirm('Are you sure?')) DeleteInventory('{!rec.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column value="{!rec.Employee_Name__c}"/> <apex:column value="{!rec.ASI_Solutions_Inventory_Number__c}"/> <apex:column value="{!rec.Location__c}"/> <apex:column value="{!rec.Make__c}"/> <apex:column value="{!rec.Model__c}"/> <apex:column value="{!rec.Purchase_Date__c}"/> <apex:column value="{!rec.Serial_Number__c}"/> <apex:column value="{!rec.Warranty__c}"/> <apex:column headerValue="Vendor"> <apex:inputField value="{!rec.Vendor__c}"/> </apex:column> </apex:pageblocktable> </apex:pageBlock> </apex:pageBlock> <apex:actionFunction action="{!DeleteInventory}" name="DeleteInventory" reRender="form" > <apex:param name="inventoriesid" value="" assignTo="{!selectedField}"/> </apex:actionFunction> </apex:form> </div> </body> </html> </apex:page>
here is the controller
public with sharing class clsController { public List<Inventory__c> inventories {get;set;} public List<Inventory__c> con {get; set;} public string selectedField {get;set;} public clsController() { LoadData(); } public void LoadData() { inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c Limit 10]; } public void DeleteInventory() { if (SelectedField == null) { return; } Inventory__c tobeDeleted = null; for(Inventory__c a: inventories) if (a.Id == SelectedField) { tobeDeleted = a; break; } if (tobeDeleted != null) { Delete tobeDeleted; } LoadData(); } public void sortMethod() { if (selectedField =='Employee_Name__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Employee_Name__c Limit 10]; else if(selectedField == 'ASI_Solutions_Inventory_Number__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by ASI_Solutions_Inventory_Number__c Limit 10]; else if(selectedField == 'Make__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Make__c Limit 10]; else if(selectedField == 'Model__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Model__c Limit 10]; else if(selectedField == 'Purchase_Date__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Purchase_Date__c Limit 10]; else if(selectedField == 'Serial_Number__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Serial_Number__c Limit 10]; else if(selectedField == 'Vendor__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Vendor__c Limit 10]; else if(selectedField == 'Warranty__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Warranty__c Limit 10]; else if(selectedField == 'Location__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Location__c Limit 10]; } public void save() { update inventories; } }thank you for any help
- Sergio Beresuita
- August 28, 2014
- Like
- 0
Method Void Error on Custom object
Hey everyone, Im fairly new to APEX and need some guidance through this simple error. The error i receive is the Method void DeleteContact() is referenced by VisualForce page(cls) in salesforce.com. Remove the usage and try again.
This is pointing to the void DeleteInventory in the controller, so I am not sure what this error is exactly pointing.
cls page
here is the controller
This is pointing to the void DeleteInventory in the controller, so I am not sure what this error is exactly pointing.
cls page
<apex:page controller="clsController" sidebar="true" showheader="false" showChat="true" > <html> <head> <title></title> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet" media="screen"/> <style> body { padding-top: 60px; } </style> </head> <body> <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">Computer Inventory</a> <div class="nav-collapse collapse"> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#else">Contact</a></li> </ul> </div> </div> </div> </div> <div class="container"> <apex:form id="form"> <apex:image value="{!$Resource.LogoAbel}" width="30%" /> <apex:pageBlock title="Computer Inventory"> <apex:pageMessages > </apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlock > <apex:panelgrid columns="2"> <apex:selectList value="{!selectedField }" size="1"> <apex:selectOption itemValue="Employee_Name__c" itemLabel="EmployeeName"/> <apex:selectOption itemValue="ASI_Solutions_Inventory_Number__c" itemLabel="ASI Solutions Inventory Number"/> <apex:selectOption itemValue="Location__c" itemLabel="Location"/> <apex:selectOption itemValue="Make__c" itemLabel="Make"/> <apex:selectOption itemValue="Model__c" itemLabel="Model"/> <apex:selectOption itemValue="Purchase_Date__c" itemLabel="Purchase Date"/> <apex:selectOption itemValue="Serial_Number__c" itemLabel="Serial Number"/> <apex:selectOption itemValue="Warranty__c" itemLabel="Warranty"/> <apex:selectOption itemValue="Vendor__c" itemLabel="Vendor"/> </apex:selectList> <apex:commandButton value="Click Here to Sort" action="{!sortMethod}" reRender="pgblcktbl"/> </apex:panelgrid> </apex:pageBlock> <apex:pageBlock > <apex:pageblocktable value="{!inventories}" var="rec" id="pgblcktbl" > <apex:column > <apex:outputLink title="" value="/{!rec.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | <a href="javascript:if (window.confirm('Are you sure?')) DeleteInventory('{!rec.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column value="{!rec.Employee_Name__c}"/> <apex:column value="{!rec.ASI_Solutions_Inventory_Number__c}"/> <apex:column value="{!rec.Location__c}"/> <apex:column value="{!rec.Make__c}"/> <apex:column value="{!rec.Model__c}"/> <apex:column value="{!rec.Purchase_Date__c}"/> <apex:column value="{!rec.Serial_Number__c}"/> <apex:column value="{!rec.Warranty__c}"/> <apex:column headerValue="Vendor"> <apex:inputField value="{!rec.Vendor__c}"/> </apex:column> </apex:pageblocktable> </apex:pageBlock> </apex:pageBlock> <apex:actionFunction action="{!DeleteInventory}" name="DeleteInventory" reRender="form" > <apex:param name="inventoriesid" value="" assignTo="{!selectedField}"/> </apex:actionFunction> </apex:form> </div> </body> </html> </apex:page>
here is the controller
public with sharing class clsController { public List<Inventory__c> inventories {get;set;} public List<Inventory__c> con {get; set;} public string selectedField {get;set;} public clsController() { LoadData(); } public void LoadData() { inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c Limit 10]; } public void DeleteInventory() { if (SelectedField == null) { return; } Inventory__c tobeDeleted = null; for(Inventory__c a: inventories) if (a.Id == SelectedField) { tobeDeleted = a; break; } if (tobeDeleted != null) { Delete tobeDeleted; } LoadData(); } public void sortMethod() { if (selectedField =='Employee_Name__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Employee_Name__c Limit 10]; else if(selectedField == 'ASI_Solutions_Inventory_Number__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by ASI_Solutions_Inventory_Number__c Limit 10]; else if(selectedField == 'Make__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Make__c Limit 10]; else if(selectedField == 'Model__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Model__c Limit 10]; else if(selectedField == 'Purchase_Date__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Purchase_Date__c Limit 10]; else if(selectedField == 'Serial_Number__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Serial_Number__c Limit 10]; else if(selectedField == 'Vendor__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Vendor__c Limit 10]; else if(selectedField == 'Warranty__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Warranty__c Limit 10]; else if(selectedField == 'Location__c') inventories = [select Employee_Name__c, ASI_Solutions_Inventory_Number__c, Make__c, Model__c, Purchase_Date__c, Serial_Number__c, Vendor__c, Warranty__c, Location__c from inventory__c where id IN:inventories order by Location__c Limit 10]; } public void save() { update inventories; } }thank you for any help
- Sergio Beresuita
- August 28, 2014
- Like
- 0