• TamaraU
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I'm new with triggers and am having trouble with making one work.

 

I have a child custom object called "Actividad" which has a formula field called "Actor Principal Indicador" that gets updated from a field in its' parent object "Indicador".

"Actividad" is also parent for the object "Entidad participante".

 

What I want my trigger to do is to update a field ("Actor Principal Indicador" - yes, it has the same name as the field in the other object) in "Entidad participante" getting the value from its parent's field "Actor Principal Indicador" (which originally gets its value from the "Indicador" objetc)

 

Is this possible?

Any help would be appreciated!

 

This is what I have so far:

 

trigger ActualizarActorPrincipal on Actividad__c (after update, after insert) {
   Set<ID> IDActividad = new Set<ID>();
    for(Actividad__c A: Trigger.new){
        List<Actividad__c> ActividadActualizada = [SELECT Id, Actor_principal_indicador__c, (Select Id, Actor_principal_indicador__c from Organizaciones_participantes__r)  FROM Actividad__c WHERE Id in :IDActividad];
        List<Entidad_participante__c> EntParticipActualizar = new List<Entidad_participante__c>();
    for (Actividad__c AA: ActividadActualizada){
        for(Entidad_participante__c EP : AA.Organizaciones_participantes__r){  if(EP.Actor_principal_indicador__c == null)
            EP.Actor_principal_indicador__c = AA.Actor_principal_indicador__c;
       EntParticipActualizar.add(EP);
                }
        
   
            update EntParticipActualizar;
       }
    }}

I'm new with triggers and am having trouble with making one work.

 

I have a child custom object called "Actividad" which has a formula field called "Actor Principal Indicador" that gets updated from a field in its' parent object "Indicador".

"Actividad" is also parent for the object "Entidad participante".

 

What I want my trigger to do is to update a field ("Actor Principal Indicador" - yes, it has the same name as the field in the other object) in "Entidad participante" getting the value from its parent's field "Actor Principal Indicador" (which originally gets its value from the "Indicador" objetc)

 

Is this possible?

Any help would be appreciated!

 

This is what I have so far:

 

trigger ActualizarActorPrincipal on Actividad__c (after update, after insert) {
   Set<ID> IDActividad = new Set<ID>();
    for(Actividad__c A: Trigger.new){
        List<Actividad__c> ActividadActualizada = [SELECT Id, Actor_principal_indicador__c, (Select Id, Actor_principal_indicador__c from Organizaciones_participantes__r)  FROM Actividad__c WHERE Id in :IDActividad];
        List<Entidad_participante__c> EntParticipActualizar = new List<Entidad_participante__c>();
    for (Actividad__c AA: ActividadActualizada){
        for(Entidad_participante__c EP : AA.Organizaciones_participantes__r){  if(EP.Actor_principal_indicador__c == null)
            EP.Actor_principal_indicador__c = AA.Actor_principal_indicador__c;
       EntParticipActualizar.add(EP);
                }
        
   
            update EntParticipActualizar;
       }
    }}