Tuesday, December 8, 2020

How to get object key prefix using apex in salesforce

This post explains how to get the object key prefix using apex in salesforce.

Below the code is to get the Account Key prefix.

Sample Code:

String strObjKeyPrefix  = Account.sobjecttype.getDescribe().getKeyPrefix();
system.debug('Key Prefix =>' +strObjKeyPrefix);
Output:



No comments:

Post a Comment