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
Prem ChauhanPrem Chauhan 

how to use Custom labels Names to update Parent records when child record gets updated dynamically..?

how to update only 1 parent records field from its child record field using 2 custom Labels [ 1:-Parent_Field_Label ,  2 :- Child_Field_Label]
below is my Trigger in that is is working fine .. But my requirement is that i want to use custom labels insted of Custom fields 
 
​trigger Job_Applic_To_Update_Hobbies_and_Interests on Job_Application__c  (after insert,after update) {
  
    Set<Id> positionIds = new Set<Id>();
    for(Job_Application__c objJobApp : Trigger.new)    {
        if(objJobApp.Hobbies_and_interests__c != ''){
            positionIds.add(objJobApp.Position__c);
            
        }
        map<id, Position__c> positionEntries = new Map<Id, Position__c>(
            [SELECT id,name,Hobbies_and_Interests__c FROM Position__c WHERE id IN : positionIds]
        );
        
        for(Job_Application__c objJobApp1 : Trigger.new)    {
            Position__c objPosition = positionEntries.get(objJobApp1.Position__c);
            if(objPosition !=null){
                objPosition.Hobbies_and_Interests__c = objJobApp1.Hobbies_and_interests__c;
                          } 
            update objPosition;
        }
    }
}

Please Any one help me How to write Code For this or any tips regarding custom labels name..
may be in future i may change the fields name but the functionality should work same i need not to change my code for changing my fields..


HOPE YOU GOT MY REQUIREMENT HELP ME SOON...
Thanks In Advance
PREM
GauravGargGauravGarg
Hi Prem,

We cannot use:
  1. Label
  2. Custom Setting
  3. Custom Metadata 

records for dynamic purpose. They all store static data to be reference. 

Hope this helps.

Thanks,

Gaurav
Skype: gaurav62990