I have a simple trigger but I cannot figure out why it's not insert Account List Item records. Here is the code.
Trigger Eisai_createAcctListItem on Affiliation_vod__c (before insert){
Set<String> affToAcctSet = new Set<String>();
List<Account_List_vod__c> existingAcctList = new List<Account_List_vod__c>();
List<Account_List_Item_vod__c> toInsertAcctListItem = new List<Account_List_Item_vod__c>();
for(Affiliation_vod__c newAff: Trigger.New)
{
if(newAff.Parent_vod__c = false)
{
affToAcctSet.add(newAff.To_Account_Value__c);
}
}
existingAcctList = [SELECT Id, Name_Substring__c FROM Account_List_vod__c WHERE Name_Substring__c IN :affToAcctSet];
for(Account_List_vod__c allAcctList: existingAcctList){
for(Affiliation_vod__c affRec : Trigger.New)
{
Account_List_Item_vod__c AccListItem = new Account_List_Item_vod__c(
Account_List_vod__c = allAcctList.Id,
Account_vod__c = affRec.From_Account_vod__c
);
toInsertAcctListItem.add(AccListItem);
}
}
Database.insert(toInsertAcctListItem,false));
}//end of trigger
Basically, what I want to happen is, after child affiliation record was inserted, the trigger should find the Account List record (Master)
where Name_Substring__c
is in the Set of named 'affToAcctSet'
then will create Account List Item record (Details)
totalRecordsInserted
andtotalRecordsFailed
?newAff.Parent_vod__c = false
(which is always false) to thisnewAff.Parent_vod__c == false
or this!newAff.Parent_vod__c
(which is true when the value is false and false when the value is true).vod__c
- what does thevod
stand for? In my line of business, it would be video-on-demand but I don't think that's it here. Curious