0

I have a requirement where i have two objects say, Product and Product line item(Both are custom objects). I have got a requirement where i need to map the fields in the product record to the product line item record whenever the Product is selected in the look-up of Product Line Item.(Product line item has got a look up relationship with product in my case). For now in my code i am mapping fields like,

Pli.Billed__c = Prod.Billed__c;

I wonder if there is anyway i can do this dynamically using Custom metadata.

So my question goes like, for mapping fields from one object to fields of another object, is there anyway i can do it dynamically using custom Metadata?

3
  • While this can be easily done using custom metadata, what is your use case? Do you really have a large # of field mappings to be managed? I don't think the object schema is well defined if you have to regularly keep copying a large # of fields from parent to direct child object. You should instead use relationship queries in apex, as needed, or make use of cross object formulae etc.
    – arut
    Commented Dec 16, 2020 at 5:19
  • Yeah i do have a large number of fields to mapped Commented Dec 16, 2020 at 5:32
  • Custom metadata entity and field references are slow to load, taking significant CPU time, so are only sensible to use for small numbers of mappings or when they are needed infrequently and for simple processing. If you need to keep the object mapping you have then I would suggest using two same-named field sets, one on each object, that must be the same length and populated with fields in the same order. Not ideal but more efficient.
    – Phil W
    Commented Dec 16, 2020 at 8:04

0

You must log in to answer this question.

Browse other questions tagged .