How to create RowID in Tables : Here is the Code or Script Code for ID creation

April 10, 2010 admin 0
If you are looking for to How to create RowID in Tables : Here is the Code or Script Code for ID creation,
Find below a simple Script or Code for generating Row ID or Record ID in Tables for Salesforce
public void viewTracking(){
if(trackingRow != null){
list rowId = trackingRow.split(‘:’);
if(rowId.size() >1){
//system.debug(‘***’+ integer.valueof(rowId[(rowId.size()-2)]));
Tracking =orderDetails[integer.valueof(rowId[(rowId.size()-2)])].Tracking;
}
}
}
Using RowID can be helpful in many ways to identify a record, count the records, classify, add, insert or delete a record or row just with a command in Tables.

How to Identify SobjectType Dynamically in Apex

January 25, 2008 admin 0
Here is a script that answers your How to Identify SobjectType Dynamically in Apex

getKeyPrefix of Schema.getGlobalDescribe can be used to identify dynamically the SobjectType in Apex.

String prefix = recordId.substring(0,3);
String objectType;
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType s : gd.values()){
if(prefix == s.getDescribe().getKeyPrefix()){
objectType = s.getDescribe().Name;
}
}

recordId consists the Id of the sobject Record for whose SobjectType needs to be identified. Above piece of code does it well.