I know that lookup is 1-M relationship between just two objects. Tried to find but so far wasn't able a proper way. Maybe someone faced the same case and can share or give an advice?
Use case: I want to link custom object (myCustom
) to one or many other standard/custom objects (whateverObject
). E.g. log object and some other use cases. So, the record of the object should have lookup to parent object and some other info. Ideally I'm looking for something like Activities that can be linked to different objects and enabled for custom objects.
Problem: If I want to reuse the same object and link it to 20-30 other objects I have to create 20-30 lookup fields but only 1 will be used. As well as in code all the time I have to know which field to populate (get it from schema or pass as parameter).
My ideas:
Create 20 lookups and populate just one. Not that efficient and scalable in my opinion.
Add a long text field to Parent object and text field to myCustom object.
Insert
myCustom
object record (populate that text field with ID ofwhateverObject
.Update my
whateverObject
and addmyCustom
object id to text as comma separated.
I think that is not the best way of doing things but then I don't have to worry about API names and so on. Another bad things - I won't get related lists and those TEXT ids won't be indexed.
Any ideas how I can implement something like this? This idea https://success.salesforce.com/ideaView?id=08730000000Bq7Z kinda the same. Upvoted but how to design this for now?
Best