You need to sign in to do that
Don't have an account?
Zac Rosenberg
Apex:CommandButton Passing Value from VF to Controller
I'm trying to create a visual force page with a table and a "request" button that will take the selected row and append it as a task.
Here's a photo of the table:
When a user hits request, I want to create a task that includes the deal name and deal owner.
Here is the VF page:
Here is the controller:
The task is successfully inserted, but the paramValue comes up as null.
What am I doing incorrectly (probably a lot ;)? How can I get the row data to be appended to the description of the task?
I've tried following https://developer.salesforce.com/forums/ForumsMain?id=906F000000095uXIAQ
Didn't help.
Thanks!
Here's a photo of the table:
When a user hits request, I want to create a task that includes the deal name and deal owner.
Here is the VF page:
<apex:page controller="A7_OppsCntrl" standardStylesheets="false" sidebar="false"> <apex:form> <table id= 'a7Table' class='display'> <thead> <tr> <th>Deal Name</th> <th>Deal Owner</th> <th>Request</th> </tr> </thead> <apex:repeat value="{!A7Opps}" var="row"> <tr> <apex:repeat value="{!A7Opps[row]}" var="cell"> <td> {!cell} </td> </apex:repeat> <td> <apex:commandButton action="{!send2Admin}" value="Request" title="Send Request to Admin" oncomplete="" reRender="block"> <apex:param value="{!A7Opps[row]}" assignTo="{!paramValue}"/> </apex:commandButton> </td> </tr> </apex:repeat> </table> </apex:form> </apex:page>
Here is the controller:
Global With Sharing class A7_OppsCntrl { static string paramValue; public static void send2Admin(){ user adminId = [SELECT id from user where name like 'Sir Admin' limit 1]; string userId = toolbox.grabUserId(); //Grabs context user ID user userName = [SELECT name from user where id = :userId]; task leadReq = new task(); leadReq.OwnerId = adminId.id; leadReq.Subject = 'New Request'; leadReq.Description = userName.name+' is requesting '+paramValue; insert(leadReq); }
The task is successfully inserted, but the paramValue comes up as null.
What am I doing incorrectly (probably a lot ;)? How can I get the row data to be appended to the description of the task?
I've tried following https://developer.salesforce.com/forums/ForumsMain?id=906F000000095uXIAQ
Didn't help.
Thanks!
http://salesforce.stackexchange.com/questions/73222/apexcommandbutton-sending-data-to-controller/73241?noredirect=1#comment95784_73241
Seems to be that I had to add a name to apex:param. So now it looks like:
Why did this fix it???
All Answers
and pass the var in the param tag not the value like below.
the method "send2Admin()" can't access it.
I get "paramValue does not exist". I also tried this.paramValue, which also doesn't work.
I think you will have to make the paramValue as instance variable instead of static variable. Can we make it instance public variable with getter and setter properties and make the method as public void send2Admin()?
Here is the updated code: Not sure if it would help to see what is in the A7_Opps mapping:
Maybe the problem is in the value being !A7_Opps[row]? That would reference a list of string...
http://salesforce.stackexchange.com/questions/73222/apexcommandbutton-sending-data-to-controller/73241?noredirect=1#comment95784_73241
Seems to be that I had to add a name to apex:param. So now it looks like:
Why did this fix it???