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:
<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 {
string paramValue;
public void setParamValue(string paramValue){
this.paramValue = paramValue;
}
public 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 '+this.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 this https://developer.salesforce.com/forums/ForumsMain?id=906F000000095uXIAQ.
Didn't help me.
Thanks!
UPDATE: It might be helpful to see how the A7Opps mapping works:
public static Map<string, list<string>> getA7Opps(){
List<List<String>> parsedCSV = new List<List<String>>();
Map<string, list<string>> A7Opps = new Map<string, list<string>>();
Map<string, list<string>> userA7Opps = new Map<string, list<string>>();
String fileString = getCSVFromDocs('A7Opps');
parsedCSV = toolbox.csv2List(fileString, '\\|');
for (List<String> row : parsedCSV){
A7Opps.put(row[0], row);
}
list<string> targetIDs = new list<string>();
string userId = toolbox.grabUserId();
targetIDs.add(userId);
list<deal__c> dealOriginator = [SELECT name, Deal_number__c, owner.id, owner.name
FROM deal__c
WHERE owner.id in :targetIDs AND Deal_number__c in :A7Opps.keySet()];
for(deal__c deal:dealOriginator){
A7Opps.get(deal.Deal_Number__c).add(deal.name);
A7Opps.get(deal.Deal_Number__c).add(deal.owner.name);
userA7Opps.put(deal.Deal_Number__c, A7Opps.get(deal.Deal_Number__c));
}
return userA7Opps;
}
EDIT:
I've updated the controller code to:
public String paramValue {get; set;}
public static void send2Admin(){
user adminId = [SELECT id from user where name like 'Sir Admin' limit 1];
string userId = toolbox.grabUserId();
user userName = [SELECT name from user where id = :userId];
task leadReq = new task();
leadReq.OwnerId = adminId.id;
leadReq.Subject = 'New Lead Request';
leadReq.Description = userName.name+' is requesting '+ paramValue; //this doesn't work
insert(leadReq);
}
paramValue cannot be referenced in the method send2Admin(), the var doesn't exist…
Best Answer
Try changing
to this
and completely removing
also add a "name" attribute to your tag like so