You need to sign in to do that
Don't have an account?
![MG Consulting MG Consulting](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Can you delete by Id or List of Ids?
Hi,
Can you delete by Id or List<Id>?
I thought you could due to documentation below, but when I pass delete an Id or a List<Id> it says "DML requires SObject or SObject list type: Id."
Thanks,
Mike
Can you delete by Id or List<Id>?
I thought you could due to documentation below, but when I pass delete an Id or a List<Id> it says "DML requires SObject or SObject list type: Id."
Code:
delete sObject | Record.ID delete sObject[] | LIST:ID[]
Mike
DML won't accept a list of ID's directly, but you can delete objects from an ID without having to issue an additional SOQL statement like so:
Id del = '003S00000099999'; // whatever ID you are deleting Contact ct = new Contact(Id = del); delete ct;
HTH
Jeremy Kraybill
Austin, TX
String pcrId= '003000789AhJKL';
Database.delete(pcrId);
To delete one Id :
thats about it, you can also delate a LIST you select with a query.
Everything is simple, insert your ID and the name of the object with which you work. You're welcome =)
public static deleteRecordById(Id id){
delete id.getSobjectType().newSObject(id);
}
Actually, You can do both of them
Here I am deleting multiple Accounts or single Account by a class through a wrapper class
ThanksAmit Kumar