Skip to main content
I have a Subgrantee object, and a Subgrantee Profile object, with a master-child relation ship (Subgrantee = master, Subgrantee Profile=child). I want to write a trigger so that:

- when the Name field in Subgrantee is updated

- The Subgrantee Profile name is also update (it's not the same, you have to append something to it)

Thanks
3 answers
  1. Mar 12, 2015, 1:24 PM

    I got the solution:

    trigger updateRR on Account(after update)

    {

    try

    {

    List<Subgrantee_Profile__c> lstRR=[Select r.Id,r.Name, r.Subgrantee__c from Subgrantee_Profile__c r where r.Subgrantee__c in : Trigger.newMap.keyset()];

    for(Subgrantee_Profile__c objRR : lstRR)

    {

    if(Trigger.newMap.containskey(objRR.Subgrantee__c) )

    objRR.Name=Trigger.newMap.get(objRR.Subgrantee__c).Mailing_State__c + Trigger.newMap.get(objRR.Subgrantee__c).Associated_Project_Number__c+' - '+Trigger.newMap.get(objRR.Subgrantee__c).Name;

    }

    update lstRR;

    }catch(Exception ex)

    {

    Trigger.new[0].addError('Error in resource request updates --'+ ex.getMessage());

    }

    }

     
0/9000