Saturday 22 September 2012

New ID.getSObjectType Method in Apex version 26 (Part of winter 13 release)

While i was going through winter 13 release notes of salesforce one of the interesting feature i found was addition of new method ID.getSObjectType.
This will be very helpful in getting the object token without making one more describe call if already in the code we have the List of ID's or ID.
Here is the small snippet i ran in new enhanced developer console(Pretty excited about this new console)
Id accid=[Select Id  from Account Limit 1].ID;
Schema.Sobjecttype inspecttype=accid.getSObjectType();
system.debug('Object Token '+inspecttype);
23:33:30:025 USER_DEBUG [3]|DEBUG|Object Token Account
As seen above this method works great if your sandbox has been updated
Also this method will help in methods where only primitive types can be passed as a parameter like @future where parameter cannot be sObject.

No comments:

Post a Comment

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...