You need to sign in to do that
Don't have an account?
John Neff
Using UPDATE with an array - is it possible?
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:
I am trying to get this statement:
to update these records:
But the changes just won't save.
Is there anything I can do differently to make this work?
Thanks,
John
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
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.
I have never used UPSERT before, but I will give it a try!
Here is the controller where I am successfully using this method: