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
Rahul AlladaRahul Allada 

How to map fields using custom metadata?

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?
Naga  AlapatiNaga Alapati
Hi Rahul,

I don't know about your requirements completely, but I think you can easily accomplish this if you define those fields on the product line item as formula fields. 

For example, You can define a formula field named 'Billed__c' on Product Line Item object with the formula 'Product.Billed__c'. So when there is a value for the product lookup field on product line item objetc, it will automatically populate the 'Billed__c' field with the Product Billed__c field value.

Thanks,
Naga