Skip to main content
Hi Team,

Is it possible to update a custom field from one object to another(Opportunity with custom object - Lookup relationship)?

Thanks & Regards,

Karthikeyan Chandran

+91-9944676540
3 answers
  1. Jul 24, 2015, 12:31 PM
    Hi,

    I created a trigger in custom object and i achived this one,

    Here the trigger i tried,

    trigger PrimeBaseRate on Prime_Rate__c (after update, after insert) {

    Static Double x;

    for(Prime_Rate__c pr : trigger.new){

    x= pr.Prime_Base_Rate__c;

    }

    System.debug('the vaulue of field is '+x);

    //created a new list for bulkifying

    list<opportunity> op = new list <opportunity>();

    //running for loop for entire table.

    for(opportunity op1 : [select id, Base_Rate__c from opportunity where isclosed=false]){

    //changing the value of the field with the static variable.

    op1.Base_Rate__c=x;

    op.add(op1);

    }

    update op;

    }

    Thanks & Regards,

    Karthikeyan Chandran

    +91-9944676540
0/9000