function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jnegijnegi 

How to get QueueSobject prefix ?

Hi All,

 

I want to get  QueueSObject record prefix . I can get Other standard objects prefix by using below mentioned code:

 

Account.sObjectType.getDescribe().getKeyPrefix();

 

but when I use QueueSobject in above code it through an error. :

 

"Method does not exist or incorrect signature: [Schema.DescribeFieldResult].getKeyPrefix();"

 

any Idea ?

 


Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

I misread your original question, I thought you had wanted to determine the SobjectType field prefix, but you actually wanted the key prefix for the QueueSobject entity (is that correct?). It is odd that this object works differently than say, accounts. I believe that behavior might be a bug of some sort, since QueueSobject.sObjectType.getDescribe() is returning a field describe instead of an object describe (Scoping issue, maybe?). That being said, you can definitely get your answer using the following mechanism:

 

 

Map<String,Schema.SobjectType> globalDescribe = Schema.getGlobalDescribe();
system.debug(globalDescribe.get('queuesobject').getDescribe().getkeyprefix());

 

 

All Answers

sfdcfoxsfdcfox

As the error message states, you're attempting to call getKeyPrefix on an DescribeFieldResult, not a DescribeSobjectResult. You'll need to call Schema.getGlobalDescribe(), and then get the appropriate entry from the map, and then call getDescribe() on that entry.

jnegijnegi

Thanks sfdcfox.

 

Could you please provide me the syntax to get prefix for QueueSobject. 

sfdcfoxsfdcfox

I misread your original question, I thought you had wanted to determine the SobjectType field prefix, but you actually wanted the key prefix for the QueueSobject entity (is that correct?). It is odd that this object works differently than say, accounts. I believe that behavior might be a bug of some sort, since QueueSobject.sObjectType.getDescribe() is returning a field describe instead of an object describe (Scoping issue, maybe?). That being said, you can definitely get your answer using the following mechanism:

 

 

Map<String,Schema.SobjectType> globalDescribe = Schema.getGlobalDescribe();
system.debug(globalDescribe.get('queuesobject').getDescribe().getkeyprefix());

 

 

This was selected as the best answer
jnegijnegi

Thanks sfdcfox once again.