+ Start a Discussion
Roshan singh 21Roshan singh 21 

how to display based on one lookup field value to second lookup field search page value on opportunity object

Hi All,

I am having one 3 object 
Note:- Account and SalesPreson__c object is not related to each other directly.
1. Account (Country__c, State__C)
2. SalesPreson__c(Country__c,State__C)
2. Opportunity( Opportunity object having Account & SalesPreson__c is lookup field)
my scenario is if the user is selecting Account and if Account country is India & State is Delhi then the second lookup field that is SalesPreson__c in this lookup search page in need to display only that Salesperson name which belongs from country India and State  Delhi.

Please, tell me how can I achieve this using trigger.
Thanks in advance.
It's very urgent.

Gulafsha MohammedGulafsha Mohammed
Hi Roshan,

We cannot achieve this through trigger. Use Visualforce page or lightning component to get the Account details like country and state and query salesperson with these selected conditions.(Show a dynamic picklist to select salesperson) 
Please mark this as best answer if this has solved your query.

Roshan singh 21Roshan singh 21
Hi Gulafsha,

Thank you so much for your reply can you please provide me sample code for this
Gulafsha MohammedGulafsha Mohammed
Hello Roshan,
First you should create a visualforce page to input the account details. Then on entering the country and state the page should rerender. for example:
<apex:page controller="ReRenderControllr">
 <!-- Render and Rerender Demo -->
     <apex:form >
           <apex:pageBlock >
                <apex:commandButton value="Refresh Lower Page Block" action="{!ShowBlockMethod}" rerender="pgblckID"/>
           <apex:pageBlock id="pgblckID">
               <b>  Output Text   : </b>   <apex:outputText value="{!OutPutString}"/>


The action will have to call an apex method from it's controller which will fetch the related salesperson from that particular country and state. This can be shown in a custom lookup.Please mark this as best answer if this has solved your query.

Hope I helped. Regards,