Skip to main content

Posts

Showing posts from September, 2021

Search for a picklist value in an org

We have a scenario where we need to search for any picklist which has a value 'Banking' in an organization. To find out this value, We are going to use Schema Class and Schema Namespace which has classes and methods to get the list of objects, fields and picklist values. Schema Class (from System Namespace) c ontains methods for obtaining schema describe information. Schema Namespace  provides classes and methods for schema metadata information. To read more,  check  Schema Class   and  Schema Namespace   Below is the sample code to search for a picklist value 'Banking' across the org.  List < Schema.SObjectType > gd = Schema.getGlobalDescribe().Values();        for ( Schema.SObjectType f : gd ) {       Schema.DescribeSObjectResult dsr = f.getDescribe();        Map<String , Schema.SObjectField > mapFieldList = dsr.fields.getMap();         for ( Schema.SObjectField field : mapFieldList.values() ) {             Schema.DescribeFieldResult fieldResult = f

Username and password parameters no longer works in the login URL

  Before Winter 22 release, Salesforce allowed the user to login  by using a username and password as GET query string parameters to the login URL.  This provided a useful trick where users normally bookmark the login url with credentials for easily login into different orgs. Login URL : https://<SFDC Instance Url>/ Parameters 1. Un - Username 2. pw - password e.g. login directly into production org. https://login.salesforce.com/?un=yourname%40salesforce.com&pw=test12345 As per the Winter 22 release ,  To improve the security, Users can no longer log in to Salesforce by using a username and password as GET query string parameters to the login URL. Users who attempt to log in using a GET query string are redirected to a login page.  Thank you for your time in reading this. Cheers :)

"Implementation restriction: FeedItem requires a filter by Id" when running query against FeedItem

Recently i faced an issue where a SOQL query against Feed Item object was failing with the error "Implementation restriction: FeedItem requires a filter by Id" SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body,  (SELECT ID, FieldName, OldValue, NewValue FROM FeedTrackedChanges ORDER BY ID DESC)  FROM FeedItem WHERE CreatedDate > LAST_MONTH  ORDER BY CreatedDate DESC The main reason as the documented here is when we want to directly query the Feed Item object, Either one of the below things should be true 1. The context user should have 'View All Data' permission in the assigned profile/permission set. 2. The class should be annotated with 'Without Sharing' Without "View All" permission every feed item examined by the query needs to be access checked and potentially discarded, which is a very expensive operation. Given that there are potentially millions of feed items in an organization, most