+ Start a Discussion
Johan Emerén 2Johan Emerén 2 

Get record id from field in current page

Hi,

I'm trying to update an apex class so that it pulls information from a custom object owned by the same account as the record in which you are performing the action.

The account is selected within the current object through a lookup field. But I'm not sure how to get that value.

public List<Business_License__c> getBusinessLicenses() {
        return [
            SELECT Licensing_Authority__c, Countries_Regions_covered__c, Expiry__c
            FROM Business_License__c
            WHERE Account.Id = :ApexPages.currentPage().getParameters().get('id')
        ];
Dev_AryaDev_Arya
Hi Johan,

this APEX class is a controller class, and if the page has the context record you want, then  ApexPages.currentPage().getParameters().get('id') should work.
Lookup relations are  queried using relationship merge fields (ending __r) customObject__r.fieldname
Could you elaborate what you are actually seeking for.

Cheers,
Dev 
Johan Emerén 2Johan Emerén 2

I want to fetch information from an object (Business_License__c). To select the correct record I want to choose one (or several) which has the same owner as the object I am currently running the action from (KYC__c).