Skip to main content Join the Agentforce Virtual Hackathon to build innovative solutions and compete for a $50k Grand Prize. Sign up now. Terms apply.
Getting error "Loop Variable Mut be of Type Account Line 7".

Here is my code.

No classes named accoutn.

trigger HasWorkPaperManager on Account (after insert, after update) {

    Map<ID, Account> parentAccount = new Map<ID, Account>();

    List<Id> listIds = new List<Id>();

    List<Id> LineItems = new List<Id>();

    for (AMS_Inventory_Rollup__c childObj : Trigger.new) {

        listIds.add(childObj.AccountID__c);

        LineItems.add(childObj.Id);

    }

  

    parentAccount = new Map<Id, Account>([SELECT id,Has_WorkPaper_Manager__c,(Select id from Ams_inventory_rollups__r where name = '511000') FROM account WHERE ID IN :listIds]);

   

    for (AMS_Inventory_Rollup__c AMSInventoryRollup: Trigger.new){

         Account myParentAccount = parentAccount.get(AMSInventoryRollup.Account);

        if(parentAccount.containsKey(AMSInventoryRollup.Account) && parentaccount.get(AMSInventoryRollup.Account).AMSInventoryRollups__r.size() > 0)

        {

            myParentAccount.Has_WorkPaper_Manager__c = true;

        }

        else

        {

            myParentAccount.Has_WorkPaper_Manager__c = false ;

        }

    }

    update parentAccount.values();

 }
3 réponses
  1. 8 août 2016, 20:45
    Your trigger is on Account object, so this line won't work:

        for (AMS_Inventory_Rollup__c childObj : Trigger.new) {

    You can only have this line with the Trigger.new

    for (Account acct : Trigger.new) {

     
  2. 9 août 2016, 18:34
    Hi Jim,

    Please mark the answer as solved. Thanks!
  3. 9 août 2016, 12:29
    Thank you, sometimes just need anothet set of eyes. Trigger should ahve been on the AMS Inventory Rollup object.
0/9000