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
ChubbyChubby 

How to get contact associated account filed value

Hi All,

I have Account object and Issue(custom object). Issue object have look up relation with Account. I have a button called create Issue on Account object which is overriden by VF page. When I click on create Issue, i want to render some fields based on associated account region. so in my controller i want to check something like below.
If(Issue__c.Account__r.Region__c == 'abc') is this the correct way? I am getting the expected value. Can some one please help me with this pls?

Thanks.
{!pramod_nishane}{!pramod_nishane}
Hi Chubby,

Please find below code for your reference:-

Issue__c issueObj = [select id,Name,Account__r.Region__c from Issue__c limit 1];
if(issueObj != null){
    if(issueObj.Account__r.Region__c == 'North'){
        //display your field as per your requirement
        system.debug('Is North Location- '+ True);
    }
    else
        system.debug('Is North Location- '+ False);
}

Log:-
User-added image

Let me know in case of any concerns.

Please mark this answer as the solution/ best answer if it solves your purpose so that it can help other community members.

Thanks,
Pramod Nishane
Salesforce Consultant
Varasi LLC
www.varasi.com
Prashant Pandey07Prashant Pandey07
Hi Chubby,

I would recommend rendering within the visualforce page..the code will be something like this..
 
<apex:inputField value="{!issue.some_issuefield__c}" rendered="{!IF(acc.Region__c == 'abc')}"/>

Let me know if you need the full code.

--
Thanks,
Prashant