• sumit choubey 5
  • NEWBIE
  • 0 Points
  • Member since 2017

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

I'm trying to create a trigger on Asset, after Undelete.

 

I simply want to set a flag to denote that the record has been undeleted.

 

 I expect that I should be able to do something like the following, but I get an "Attempt to de-reference a null object" error on the for loop line.

 

 

trigger Asset_Intercept_UnDelete on Asset (after undelete)

{

 

    for(Asset undeletedAsset : trigger.old)

  {

     Asset theAsset = [select undeleted__c from Asset where id in :trigger.old];

     theAsset.undeleted__c = true;

     update theAsset;

  } 

}

 

 

Any help or pointers are greatly appreciated.

 

 

Thanks

Jon