New answers tagged dml
2
votes
Cleaner way to filter specific object ids from List <String>?
In addition to the simplified type check that @Adrian Larson pointed out, you can also change:
UseFulObject__c uo = (UseFulObject__c) s.getSObjectType().newSObject(s);
uo.IsActive__c = false;
...
4
votes
Accepted
Cleaner way to filter specific object ids from List <String>?
What you have already looks good. The only optimization I see is you can just compare the token directly, you don't need String.valueOf.
if (Id.valueOf(s).getSObjectType() == UsefulObject__c....
Top 50 recent answers are included
Related Tags
dml × 487apex × 312
trigger × 84
unit-test × 37
visualforce × 35
soql × 35
dmlexception × 31
batch × 29
exception × 24
update × 23
database × 22
callout × 18
governorlimits × 16
upsert × 14
class × 13
error × 13
insert × 13
sobject × 12
list × 10
future × 10
dml-operations × 8
webservices × 7
before-trigger × 7
performance × 7
delete × 7