• KVP
  • NEWBIE
  • 0 Points
  • Member since 2011

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

The boards have been really supportive of late, so, firstly, thanks, and, secondly, any help with the following problem would be much appreciated.

 

I have an object (Assessment__c) related to Account from which I am triggering code that executes on lists of accounts. The way the system is set up means that each account has two Assessment objects, which start off with the Recommendation__c picklist at --None selected--. When this changes, i.e. someone makes a recommendation, I want the trigger to fire and put the related account in the appropriate list of accounts and send that list to the appropriate method in the Assessments class.

 

I've tested the methods that I'm calling using system log and everything's good with them, but I can't get the following trigger to fire. I have a sneaking suspicion that it may be something to do with either:

  1. Recommendation__c is a picklist and therefore non-nillable, although I've dealt with that by using '', which I've read on the boards is equivalent to null for picklists.
  2. The condition on the related account - am I allowed to do this with Apex, or should I be getting a list of related accounts and iterating through those?

Thanks in advance for any help!

 

 

trigger RecommendationMade on Assessment__c (after update) { //Create list of account IDs for which a second recommendation has been made List<ID> SecondRecIDs = new List<ID> (); //Create list of account IDs for which only one recommendation has been made List<ID> FirstRecIDs = new List<ID> (); //Iterate through trigger set for(Integer i=0; i<Trigger.new.size(); i++){ if(Trigger.new[i].RecordTypeId == '01280000000BR0VAAW' && Trigger.old[i].Recommendation__c == '' && Trigger.new[i].Recommendation__c != '' && Trigger.new[i].Account__r.Initial_Enquiry_Sub_stage__c == 'Awaiting one assessment'){ SecondRecIDs.add(Trigger.new[i].Account__c); } else if(Trigger.new[i].RecordTypeId == '01280000000BR0VAAW' && Trigger.old[i].Recommendation__c == '' && Trigger.new[i].Recommendation__c != '' && Trigger.new[i].Account__r.Initial_Enquiry_Sub_stage__c == 'Awaiting two assessments'){ FirstRecIDs.add(Trigger.new[i].Account__c); } } //Create list of accounts for which the second recommendation has been made List<Account> SecondRec = new List<Account>([SELECT Name FROM Account WHERE Id IN :SecondRecIDs]); //Pass this list to the Assessments class Assessments.decideActionIEF(SecondRec); //Create list of accounts for which only the first recommendation has been made List<Account> FirstRec = new List<Account>([SELECT Name FROM Account WHERE Id IN :FirstRecIDs]); //Pass this list to the Assessments class Assessments.updateIEFsubStage(FirstRec); }