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
Niraj Kr SinghNiraj Kr Singh 

How to create a "Related to" picklist lookup field

My requirement is to create a field like "Related to" in this image.
Step1: Picklist with the Objects
Step2: On select of any one object, need to display all related records
Requirement to create a field like "Related to" field in this picture
Give me quick suggestion.

Thakns Niraj  
Best Answer chosen by Niraj Kr Singh
Rahul SharmaRahul Sharma
You would need to create custom functionality if you want to achieve something like that.
Create a picklist fields with available object names in related to and create custom lookup as mentioned in Jeff's blog (http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/).
In the javascript function: baseURL(refer blog post page: MyCustomLookup), add a parameter to dynamically load the pass the object name to the new page.
// Following is the url of Custom Lookup page. You need to change that accordingly
baseURL = "/apex/CustomAccountLookup?txt=" + txtId + '&objectName=' + objectApiName;

Then read objectApiName in CustomAccountLookupController to dynamically fetch the records using dynamic SOQL and List<sObject>.

Hope it helps!

All Answers

Rahul SharmaRahul Sharma
You would need to create custom functionality if you want to achieve something like that.
Create a picklist fields with available object names in related to and create custom lookup as mentioned in Jeff's blog (http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/).
In the javascript function: baseURL(refer blog post page: MyCustomLookup), add a parameter to dynamically load the pass the object name to the new page.
// Following is the url of Custom Lookup page. You need to change that accordingly
baseURL = "/apex/CustomAccountLookup?txt=" + txtId + '&objectName=' + objectApiName;

Then read objectApiName in CustomAccountLookupController to dynamically fetch the records using dynamic SOQL and List<sObject>.

Hope it helps!
This was selected as the best answer
Kesavarapu Gowtham 3Kesavarapu Gowtham 3

Hey! @Niraj,

Coul you share me the Source code for that part ....Actually I am stuck and not gettting how to approach
 

seo antalyaseo antalya
SEO Antalya (https://seo-antalya.com.tr/) primarily ensures that the right keywords are determined for your site.
ashar killoashar killo
How Do I Set Up Salesforce Lookup Fields with Filters?
Click on SetUp (Gear Icon) and then click on the Object Manager.
Click on the object you will be adding the Look Up field to. ...
Select Fields & Relationships and thenNew.
Select Lookup Relationship from the Data Type list and click Next.
Regards: apktrolly (https://apktrolly.com/)
ashar killoashar killo
2nd method: 
Add a Lookup Field to a Page Layout
Click. ...
Click the Object Manager tab.
In the list of objects, click the object you want to add the field to. ...
Click Fields & Relationships.
Click New.
Select Lookup Relationship and click Next.
Select the related object (for example, Language if you want to add a Language field).

Regards: rats urin smell  (https://greenratcontrol.com/how-do-i-get-rid-of-the-rat-urine-smell-in-my-house/)
steve diaz 7steve diaz 7
To create a "Related to" picklist lookup field in Salesforce, create a custom picklist field and a new lookup field. Set the Related To object as the object you want to relate to and create a dependency between the picklist field and the lookup field. Map each picklist value to the appropriate lookup filter criteria, and test the field to ensure it works as expected. Refer this resource (https://www.igmguru.com/cyber-security/ccsp-isc2-certification-training/).