+ Start a Discussion

Update new record from flow designer with trigger

Hello everyone,


Well, I have been trying to get my head around this trigger but I haven't been able to get it right, kind of desperate now :( , that is why I'm here. Kind of new to APEX development too, so any help will be much appreciated. 


I have a flow that will create a new record using Data Target Elements on a customer object and that is all fine after finishing the flow process. The new record is created without any problems.

Things get bad when I'm trying to do use a trigger that will update some of the fields that are part of that new entry that it has have been created with the flow.

When I compile the trigger it looks fine and there are not errors but when I run the all thing the new records dont get updated on that particular field. (v.Honorarium2__c)

The script:


trigger NewIbenExpenses on IBEN_Expenses__c (before insert) {
  List <IBEN_Expenses__c> newExpenses = new List <IBEN_Expenses__c> ();
      for(IBEN_Expenses__c o: Trigger.new) {
          IBEN_Expenses__c v = new IBEN_Expenses__c (id = o.id);
              if (v.External_Reference_Number_Flow__c =='W045'){
               v.Honorarium2__c = '12.4567.3456.5678'; 


    try {
        insert newExpenses; 
    } catch (system.Dmlexception e) {
        system.debug (e);

I'm going to keep trying but any directions on how to successfully accomplish this will be a total relief.





Nevermind, I got it ...




Nevermind ... I got it