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
Sri 7Sri 7 

how to update lookup field based on text field in the same object by using triggers. please help me and send me the code

Scenario 1: The ‘C Name Lookup’, field has the ability to reflect itself if it is at the top of the Hierarchy. 
Given there's an Salesforce account with a 'CI company ID'
and 'CI company id' is equal to the 'CaI Ultimate parent Company ID'
When 'CaI Ultimate parent Company ID' is created or modified and 'Override C Name' is not checked
Then the ‘C Name Lookup’ field should be the 'Account' itself.
RazaRaza
HI Hari Sri 7,
Try this code---

trigger TriggerOnAccount on Account (after insert , after update) {
    for(Account  ac:Trigger.New){
        if(ac.CName__c != null){
            ac.CI_company_ID=ac.CName__c;
            
            
        }
    }

}
Thanks 
Raza
Raj VakatiRaj Vakati
Try this
 
trigger TriggerOnAccount on Account (after insert , after update) {
    for(Account  ac:Trigger.New){
        if(ac.CName__c != null && ac.Override__cName__c!=null){
            ac.CI_company_ID=ac.CName__c;
            
            
        }
    }

}

 
Raj VakatiRaj Vakati
trigger TriggerOnAccount on Account (after insert , after update) {
    for(Account  ac:Trigger.New){
        if(ac.CName__c != null && ac.Override__cName__c!=false){
            ac.CI_company_ID=ac.CName__c;
            
            
        }
    }

}

 
Sri 7Sri 7
not working