Skip to main content
John Neff (Ring2Media) a posé une question dans #Visualforce
Hello - 

I have a controller with a variable that is output as an array - and I would like to use UPDATE to give my users the ability to make in-line edits to records displayed an a VF page.  Is this at all possible? 

Here is my controller:

public with sharing class QualOpController

{

public List <Opportunity> Opty {get;set;}

public list<String> campaigns {get;set;}

public PageReference saveOp(){

UPDATE Opty;

return null;

}

public String getName(){

return 'QualOpController';

}

public void load()

{

campaigns= new List<String>();

Opty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ];

Set<String> campaignSet = new Set<String>();

for (Opportunity j : Opty)

campaignSet.add(j.Vert_Med__c);

for (String campaign : campaignSet)

{

campaigns.add(campaign);

}

campaigns.sort();

}

}

I am trying to get this statement:  

 

public PageReference saveOp(){

UPDATE Opty;

return null;

}

public String getName(){

return 'QualOpController';

}

to update these records: 

 

campaigns= new List<String>();

Opty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ];

But the changes just won't save. 

Is there anything I can do differently to make this work? 

Thanks, 

John
2 réponses
  1. 21 juin 2016, 14:55
    John: There is nothing that you are doing to the Opty records, all I see is a query and a subsequent Update Opty but no field is being updated.

    I think in your public PageReference saveOp(){ you want something like upsert campaigns which I see being manipulated in your Load method after the query. 
0/9000