You need to sign in to do that
Don't have an account?
Jim Montgomery
Error Loop Variable must be of type account
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();
}
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();
}
for (AMS_Inventory_Rollup__c childObj : Trigger.new) {
You can only have this line with the Trigger.new
for (Account acct : Trigger.new) {
All Answers
for (AMS_Inventory_Rollup__c childObj : Trigger.new) {
You can only have this line with the Trigger.new
for (Account acct : Trigger.new) {
Please mark the answer as solved. Thanks!