Friday, 24 March 2017

How to get list view id in apex class

Arpit Sharma
salesforce
Get list view id  using apex class in salesforce first we need to describe organization sobject by using below function

Step 1 - 

Schema.getGlobalDescribe() - This map contains organization object. map populate during run time based on permission. Key of map is sobject name and value is Sobject tokens.token is serializeable reference to sobject. 

Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();

Step 2-

Suppose if we want to describe Standard object account then we need to retrieve account token from map,If your org have namespace then you need to add namespace to custom object name because map contains object name with namespace as key.

Schema.SObjectType accInfo =  Schema.getGlobalDescribe().get( 'Account' );

Step 3-

Now we will describe Account object using getDescribe(), Return result is not serializeble, result contains all describe property of object or fields 

DescribeSObjectResult accDesc = accInfo.getDescribe();

Step 4-

Now we need to reterive object List view id  from descrbie sobject result.

String listViewId = accDesc.getKeyPrefix();




About the Author

Arpit Sharma / Author & Editor

Certified Salesforce Developer | Salesforce Developer at Cognizant | Blogger

1 comments:

  1. Casino games from Microgaming - Wooricasinos
    In-game 포커 용어 slots are 안전한 사이트 great with bonuses, as they are one of the best and most enjoyable 카카오스포츠 Play games from Microgaming casino to Play 해외에서 축구 중계 사이트 Roulette online. 크레이지 슬롯

    ReplyDelete