+ Start a Discussion
brozinickrbrozinickr 

Filter Data of a Related List by Record Type

Hello,

 

I was given the requirement to make a related list for one of our Custom Objects to be filterable.  From what I have gathered, it seems that you have to create a VF page to be able to do this.

 

Is it possible though for you to filter dynamically?  For example, the object in question, Targeted_Offer__c has two record types, Big Deal and Storefront.  If a User who has a Department of Big Deal is to click into an Account, would it be possible just to show Big Deal (so match the Department with name of the Record Type) Targeted Offers?  Or could I just do this more simply, and just only display records with the record type assigned to that User's profile?

CheyneCheyne
Maybe you could use the UserInfo class in the controller to query for the current user's Department and then filter the Targeted_Offer__c list by RecordType.Name.

String department = [SELECT Department FROM User WHERE Id = :UserInfo.getUserId()].Department;
List<Targeted_Offer__c> offers = [SELECT Id, Name FROM Targeted_Offer__c WHERE RecordType.Name = :department];