You need to sign in to do that
Don't have an account?

How to use parent object fields api names from custom settings in apex
Hi All,
I have designed a lightning component to insert products under one of custom object.
I can use same component in any custom objects without changing piece of code, i am storing the parent object fields api names in custom setting,
when inserting products i need to bind parent fields api names from custom settings.
I have searched a lot in google, still i am not able to find solution to achive this.
Thanks.
I have designed a lightning component to insert products under one of custom object.
I can use same component in any custom objects without changing piece of code, i am storing the parent object fields api names in custom setting,
when inserting products i need to bind parent fields api names from custom settings.
I have searched a lot in google, still i am not able to find solution to achive this.
Thanks.
I don't think you need custom setting here. You can dynamically get the field API names using $ObjectType.
The $ObjectType global variable provides access to a variety of schema information about the objects in your organization. Use it to reference names, labels, and data types of fields on an object, for example.
$ObjectType is a “deep” global variable, and offers the opportunity to use it in a “double dynamic” reference, like so:
Eg: This Retrieves all the API names for Product Object. Reference : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_globals_objecttype.htm
Regards,
Avishek
All Answers
I don't think you need custom setting here. You can dynamically get the field API names using $ObjectType.
The $ObjectType global variable provides access to a variety of schema information about the objects in your organization. Use it to reference names, labels, and data types of fields on an object, for example.
$ObjectType is a “deep” global variable, and offers the opportunity to use it in a “double dynamic” reference, like so:
Eg: This Retrieves all the API names for Product Object. Reference : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_globals_objecttype.htm
Regards,
Avishek
First thank you for your valuable replay.
I am getting the api names from $ObjectType. But when inserting product records i am not able to using return api name. here i have hard coded the parent lookup api name (Sales_Deal__c), but i need to place return api name from either custom setting or $ObjectType.
Thanks,
Narendra