• ethan grey
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
how do i remove file, poll, etc action links on feed view, i tried removing from edit layout but they came back...
Still having a hard time wrapping my head around classes. If someone could please help me create a class for the the below trigger. I'd like to learn/ understand this better for my self. So if you wouldn't mind, if your willing to help write it, could you please add some discriptive comments withing the class so I can understand the relationship between the trigger and the class. Thx much
 
trigger UpdateChildAccount on Account (after update){

//create a List of all accounts being saved
List<account> accountsBeingSaved = [SELECT id, name, parentId FROM Account WHERE parentid IN :trigger.new]; 

//create an empty List to hold child accounts later on
List<account> childAccountsToUpdate = new List<Account>(); 

	//loop through all Accounts being saved and call it 'a'
	for(Account a:trigger.new)
	{
		for(account ac:accountsBeingSaved) //loop through first list of all accounts being saved and call it 'ac'
		{ 
		if(ac.parentid == a.id) //'ac' is a child and 'a' is the parent
		{
			//add this child account to our List
			childAccountsToUpdate.add(new Account(Id=ac.Id,OwnerId=a.OwnerId,Approval_Progress__c=a.Approval_Progress__c,Status__c=a.Status__c)); 
		} 
		}
	}
	//check to see if the List is empty or not 
	if (childAccountsToUpdate.size() > 0)
	{ 
		try 
		{
			update childAccountsToUpdate; //update the child accounts
		} 
		catch(DmlException e) 
		{ 
			//catch exceptions in system.debug
			System.debug('An unexpected error has occurred: ' + e.getMessage());
		}
	}

}