+ Start a Discussion
Amrin.Amrin. 

Unable to update parent field from child object.. Please help!!!!!!!!!!!!!!!

 

Hi,

 

I need help in updating a parent record field with Yes or No value.

 

When I create a child record with lookup field value as hardcoded value, trigger get save but doesnt allow to save child record.

This is the code i am not able to save the child record. On child record I have visualforce page.

 

trigger ENT_Trigger_PopulateDistressedAA on ENT_NMTC_Distressed_Area_Association__c (after insert, after update)
{
    set<id> DealIDs = new set<id>();
    set<id> DdataIDs = new set<id>();
    
    for(ENT_NMTC_Distressed_Area_Association__c l : trigger.new)
    {
        DealIDs.add(l.NMTC_Deal__c);
    }
   
    List<ENT_NMTC_Deal__c> deals= [select id, PovRate2530__c from ENT_NMTC_Deal__c where id in :DealIDs ];
    
      deals[0].PovRate2530__c = 'No';
      
        
  for(ENT_NMTC_Distressed_Area_Association__c l : trigger.new)
        { 
        
           if(l.NMTC_Deal__c == 'Poverty Rates Greater Than 25 Percent')
           {
            deals[0].PovRate2530__c = 'Yes';
           
           }

        else

         {
             deals[0].PovRate2530__c = 'No';  
         }
        }
    update deals;    
}

 

This code executes but doesnt work...

As i have VF page on child object its not allowing me to save the record.

 

I feel its a lookup field (NMTC_Deal__c) so its not reading the value.. may be I am wrong.

 

Please help!!!!

 

bob_buzzard can u pls help??

WaveOCWaveOC
if(l.NMTC_Deal__c == 'Poverty Rates Greater Than 25 Percent')

 I thought that this is an ID field because this it's lookup, so in this case you will always have 'No' in PovRate2530__c