0

New bee.

I need to copy Long Text Area field - Quote_Methods__c at Account Level to Opportunity Level field - Quote_Instruc__c. I know it be cannot be done by formula, and workflow/process builder is work around but I need something that changes the field data at opportunity level dynamically, when the data in Quote_Methods__c at Account level is changes. It should apply to all child records [opportunities]. I think can be done by before update trigger on Account by using try and catch error method but not that expert in coding level. Please help me with sample code/ anything. I appreciate your time and help.

Thanks, J

2

Your requirement can be achieved by Process Builder

These are the steps:

Choose Object

Account (Start the process = When a record is created or edited) enter image description here

Define Criteria

Account.Quote_Methods__c is changed

enter image description here

Update Records

Records [Account.Opportunities]

Field: Quote_Instruc reference [Account].Quote_Methods__c

enter image description here

If any changes made on Quote_Methods__c of Account record, it will update Quote_Instruc__c of all the opportunities.

By the way, in case you want to update any specific opportunities then Trigger is the only option.

| improve this answer | |
  • Thank you so much for solution. I really appreciate it. But I looking for something that updates dynamically [without need to edit the child records to see changes of parent object field]. Something that acts like formula field. – Gidy Jul 19 '16 at 2:06
  • @Gidy your requirement is not clear. Read about capabilities of Formula, Process Builder and Trigger – Santanu Boral Jul 19 '16 at 2:09
  • Mark the suitable best answer and close your question – Santanu Boral Jul 19 '16 at 2:17
  • I'm not still clear with answer cropredy is helping me out... thank you so much for your time and wouldn't think you sound pleasing, hope at least you will be sound polite to the people in future – Gidy Jul 19 '16 at 2:26
  • We people are professionals, don't try to please anybody here – Santanu Boral Jul 19 '16 at 3:15
0

You can try the below trigger:

trigger demoTrigger on Account(before update){
    list<opportunity> oplist = new list<opportunity>();
    for(account acc : [select id, Quote_Methods__c, (select id, Quote_Instruc__c from opportunities) from account where id IN: trigger.new )]){
        for(opportunity op : acc.opportunities){
            if(acc.Quote_Methods__c != null){
                op.Quote_Instruc__c = acc.Quote_Methods__c;
                oplist.add(op);
            }
        }
    }
    if(!oplist.oisEmpty()){
        update oplist;
    }
}

Please let me know if this helps.

| improve this answer | |
  • N.B. - the isEmpty test is superfluous (and has a typo also) - SFDC does not consumer DML governor limits on empty lists – cropredy Jul 19 '16 at 1:51
  • @cropredy: I think it worked but I have a question though. Does it update dynamically like the formula field. For example, If you do changes on field which does have formula linked to child field, it changes data on child field too [no need to perform action on child record to see the change]. So, does it do something same?? Does it also update the child field if we delete data on parent field?? – Gidy Jul 19 '16 at 2:03
  • @Gidy - (1) above trigger, for each Account in trigger set, pushes the value of Account.Quote_Methods__c into all children Opportunity.Quote_Instruc__c. (2) If Account.Quote_Methods__c is cleared, the above trigger does not clear the children Opportunities Quote_Instruc__c. – cropredy Jul 19 '16 at 2:09
  • @cropredy ... so if I change something at account level "Account.Quote_Methods__c it pushes into all children Opportunity.Quote_Instruc__c dynamically. I mean like formula field. Would I see the changes without or even before I click edit Opportunity record? How can I make it happen to delete/clear the children Opportunities.Quote_Instruc__c on deleting/clear of Account.Quote_Methods__c? – Gidy Jul 19 '16 at 2:14
  • @Gidy just try the process builder, your this requirement will work – Santanu Boral Jul 19 '16 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.