I'm trying to pass a parameter of an Object to a controller with this code block:
<apex:commandButton value="Accept" action="{!Accept}" >
<apex:param name="deal" value="{!deal.id}" assignTo="{!dealId}"/>
</apex:commandButton>
But Visualforce always gives following error:
List has no rows for assignment to SObject Error is in expression '{!Accept}' in component in page dealviewer: Class.DealViewerController.Accept: line 34, column 1
When I debug the controller in Developer Console it tells me I'm passing a null value:
// click action button Accept
public void Accept() {
String dealId = apexpages.currentpage().getparameters().get('dealId');
System.debug(dealId);
Deal_Action__c dealac = [SELECT Action__c, Contact__c FROM Deal_Action__c WHERE Deal_Action__c.Deal__c = :dealId];
dealac.Action__c = 'Accepted';
update dealac;
}
Anyone knows the solution to this problem?