Skip to main content

Hello everyone,

Through searching various past threads it looks like this questions has been asked a few times, however I am hoping to get some specific help.

I've just last week started dedicating myself to learning to develop (SF99!)  So I understand this is beyond my range, but this is a need at my current Org, and I thought it would be fun to actually try to do some development.

Note* I understand that a junction object could be an option here.  Given the users that will be using these objects, the fewer clicks the better so I need to stick with this model.

 

We have a Contract Agreement Object that has 5 lookup fields for parties that can be related to the Contract Agreement.  On the Party Object, I have 5 list.  I would like to combine them into one list, and display them on the Party object.  Here is what I have for code so far,  I'm a newbie so I'm sure I am far off, but I'm excited to learn.

public class CombineContractAgreement {

public CombineContractAgreement(ApexPages.StandardController controller) {

}

Public List <Contract_Agreement__C> AllRelatedAgreements;

Public List<Contract_Agreement__c>GetAllRelatedAgreement()

{

AllRelatedAgreements = [SELECT id, RecordTypeId, APXT_Redlining_Status__c, APXT_Redlining__Effective_Date__c, Agreement_Name__c FROM Contract_Agreement__c

WHERE //Current record is value on any 1 of 5 lookup fields on the Contract Agreement Record.//

return AllRelatedAgreements

}

 

Any help you can provide will be greatly apprchated.

 
7 risposte
  1. 12 ott 2020, 22:32

    Hi Upton, 

    Sorry, I missed your comment here. 

    public class CombineContractAgreement {

    Id LegalEntityId;

    public CombineContractAgreement(ApexPages.StandardController controller){

    LegalEntityId = ((SB_Legal_Entity__c)controller.getRecord()).Id;

    }

    public List<APXT_Redlining__Contract_Agreement__c>GetAllRelatedAgreement()

    {

    List <APXT_Redlining__Contract_Agreement__c> AllRelatedAgreements;

    AllRelatedAgreements = [SELECT id, RecordTypeId, APXT_Redlining__Status__c, APXT_Redlining__Effective_Date__c,

    Agreement_Name__c FROM APXT_Redlining__Contract_Agreement__c WHERE Customer_Legal_Entity__c = :LegalEntityId OR Customer_Legal_Entity_2__c = :LegalEntityId OR

    Customer_Legal_Entity_3__c = :LegalEntityId OR Party_4__c = :LegalEntityId OR Party_5__c = :LegalEntityId];

    return AllRelatedAgreements;

    }

    }

    .getRecord() returns the original object and so we need to modify our code a bit to get the Id. 

    I hope this helps.

0/9000