You need to sign in to do that
Don't have an account?

Need help with DML requires SObject or SObject list type
I am getting this error "DML requires SObject or SObject list type: Set<Status__c> " when i tried to save the class. This is my code.
Apex Class:
List<Status__c> OpprtyToUpsert = new List<Status__c>();
Set<Status__c> OpprtyToset = new Set<Status__c>();
Status__c acc = new Status__c();
for (OppWrapper avar : OppWrappersList )
{
if (avar.UpdatePrev == True)
{
if (avar.acc.id != null)
{
avar.acc.Satisfied_By_Previous_Deal__c = true;
OpprtyToUpsert.add(avar.acc);
OpprtyToset.addAll(OpprtyToUpsert);
}
}
else if (avar.UpdateSta == True)
{
if (avar.acc.id != null)
{
avar.acc.Current_Status__c = selectestatus;
OpprtyToUpsert.add(avar.acc);
OpprtyToset.addAll(OpprtyToUpsert);
}
}
}
upsert OpprtyToset;
I am getting duplicate id error when i tried to update the records so i converted List to Set and tried to update. But i cant save the class it is showing the above error. Can anyone help me? Thanks in advance.
Apex Class:
List<Status__c> OpprtyToUpsert = new List<Status__c>();
Set<Status__c> OpprtyToset = new Set<Status__c>();
Status__c acc = new Status__c();
for (OppWrapper avar : OppWrappersList )
{
if (avar.UpdatePrev == True)
{
if (avar.acc.id != null)
{
avar.acc.Satisfied_By_Previous_Deal__c = true;
OpprtyToUpsert.add(avar.acc);
OpprtyToset.addAll(OpprtyToUpsert);
}
}
else if (avar.UpdateSta == True)
{
if (avar.acc.id != null)
{
avar.acc.Current_Status__c = selectestatus;
OpprtyToUpsert.add(avar.acc);
OpprtyToset.addAll(OpprtyToUpsert);
}
}
}
upsert OpprtyToset;
I am getting duplicate id error when i tried to update the records so i converted List to Set and tried to update. But i cant save the class it is showing the above error. Can anyone help me? Thanks in advance.
Please let us know if this will help you.
Thanks
Amit Chaudhary
All Answers
Hope this help
I have tried both your codings but still i am getting 'Duplicate id in List' error.
Thanks
Vivekh
Please let us know if this will help you.
Thanks
Amit Chaudhary