+ Start a Discussion
AlibabaAlibaba 

Mystery Bug: Passing parameters to controller using custom buttons

Hi, I was wondering if anyone has seen the following behavior:

I have a custom button (actually a few of them), that creates a VF page with a custom controller so I can create a mix of Case/Opportunity on one page. I pass a few variables to the controller using the  ApexPages.currentPage().getParameters().get('varname') function.

It works perfectly more than 99% of the time. Once in a while though, the variables are simply not passed or have a null value. I cannot recreate the bug, so it's very difficult to debug. Even if I turn on the logs, they always go past the allowed 20 calls before being disabled.

Is this a strange bug in SF? Should I not be passing parameters this way?

Thanks very much
ShashankShashank (Salesforce Developers) 
It depends on whether the parameter is passed in the URL. If the parameter that you are trying to get is not passed in the URL, this will happen. When it happens, check if the parameter is passed correctly in the page URL. This might give some clues.