How can I retrieve values (objects names) held in search scope (Polymorphic pick list) of 'Related To' field (what) defined in Task and Entity SObjects using Apex?

want to retrieve these all field values of search scope shown in red marked area

Search Scope pick list

Please help me out for the same I have tried a lot but enable to find the solution.

Thank you.

1 Answer 1

Set<Schema.SObjectType> objActivityAllowed = new Set<Schema.SObjectType();
String objectNames = '';
for(Schema.SObjectType objectType : Task.WhatId.getDescribe().getReferenceTo()){
    objectNames += '\n' + objectType;

This code will retrieve all the objects which Allow Activity checkbox is checked and shown in search scope of 'Related To' field (What) of Task.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .