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
randombardrandombard 

Adding List view of related accounts assets to a custom object

Hi All,

 

I am very sorry if I have posted this in the wrong place but this seems to be the best pace to ask.

 

Is it possible to show the assets from the related account (master detail) on the custom object.

 

I dont want to create a joining object or do a many to many so a visual force page seems to be the best option but I just cant work out how to get to what I want.

 

R

randombardrandombard

ok so far I have the following cobled together from sourses online

 

Public Class Assetpage{
private List<Asset> azzets;
    Private MY_Custom_object__c Mcust;
    Public Assetpage(ApexPages.StandardController controller){
    this.RSCcons = (MY_Custom_object__c)controller.getRecord();
    }
         public List<Asset> getAzzets()
         {       
          MY_Custom_object__c acc =   [Select id, MY_Custom_MastrDetail__r.id FROM MY_Custom_object__c where 
         id = :Mcust.id];   
                 azzets = [Select Name, PurchaseDate, UsageEndDate 
                 From Asset where Account.id = :acc.MY_Custom_MastrDetail__r.id];        
                 return azzets;    
                 }
                 }

 

 

Now how do I invoke this class?

randombardrandombard

Its fine I managed to get prety much the result I was looking for using the following:

 

<apex:page standardController="MY_Custom_object__c" extensions="Assetpage">
<apex:pageBlock >
<apex:pageBlockTable value="{!Azzets}" var="acc">
     <apex:column headervalue="Name"><apex:outputLink value="/{!acc.id}">{!acc.name}</apex:outputLink></apex:column>
     <apex:column value="{!acc.PurchaseDate}"/>
     <apex:column value="{!acc.UsageEndDate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 It would be nice to make this sortable so thats the next part I will work on.