Skip to main content
Hello, 

I am trying to add UPDATE functionality to a controller and am getting the error: DML requires SObject or SObject list type: List<String>

However my variable is set up like this: public List<String> campaigns {get;set;}

I am not sure how to achieve the proper syntax here, and was hoping that someone out there in developerland would be able to help me!

Here is my (broken) controller: 

 

public with sharing class QualOpController

{

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

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

public PageReference saveOp(){

UPDATE campaigns;

return null;

}

public String getName(){

return 'QualOpController';

}

public void load()

{

campaigns= new List<String>();

listOfOpty = [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 : listOfOpty)

campaignSet.add(j.Vert_Med__c);

for (String campaign : campaignSet)

{

campaigns.add(campaign);

}

campaigns.sort();

}

}

Thanks in advance!

John

 
3 个回答
  1. 2016年6月21日 16:32
    Hi Jeff; Sorry my bad, I know I mentioned this in the earlier post, but what is the thought behind lines 22-30 in your code. You can perform DML operations only on List Object not on Sets of Strings.That is why you are getting the error. I would suggest you put back update listOfOpty and set the debug log to see what is happening behind the scenes as your earlier post mentioned that it did not update opportunities at all.
0/9000