You need to sign in to do that
Don't have an account?
Bmart
Initial term of field expression must be a concrete SObject:ID
Hi I'm trying to create a trigger to do the following.
On Line Item Revision object if a record is created I want to query the Line item Revision Parent Object and see if there is a Parent that exists with the matching WF_ID__c value, and if not I want to create a new parent.
On Line Item Revision object if a record is updated I want to query the Line item Revision Parent Object and see if there is a Parent that exists with the matching WF_ID__c value, I want to update the trigger__c field by incrementing it by 1.
I can get the first part to work in that i can get it to create a parent, but when trying to update an existing parent I get the following error with my code "Initial term of field expression must be a concrete SObject:ID"
If anyone can assist in helping understand what I'm doing wrong that would be greatly appreciated. Thank you.
On Line Item Revision object if a record is created I want to query the Line item Revision Parent Object and see if there is a Parent that exists with the matching WF_ID__c value, and if not I want to create a new parent.
On Line Item Revision object if a record is updated I want to query the Line item Revision Parent Object and see if there is a Parent that exists with the matching WF_ID__c value, I want to update the trigger__c field by incrementing it by 1.
I can get the first part to work in that i can get it to create a parent, but when trying to update an existing parent I get the following error with my code "Initial term of field expression must be a concrete SObject:ID"
If anyone can assist in helping understand what I'm doing wrong that would be greatly appreciated. Thank you.
trigger Create_Line_Item_Parent_On_Line_Item_Revisions on Line_Item_Revisions__c (before update,after insert, after update, after delete, after undelete) { // create a set of all the unique line item revision records based on WF ID List<string> LIRevisions = new List<string>(); for (Line_Item_Revisions__c lir : Trigger.new) { LIRevisions.add(lir.wf_id__c); } List <Line_Item_Revision_Parent__c > LineItemParentstoCreate = new list <Line_Item_Revision_Parent__c> (); List <Line_Item_Revision_Parent__c > LineItemParentstoUpdate = new list <Line_Item_Revision_Parent__c> (); List <Line_Item_Revision_Parent__c > LineItemParentList=[Select WF_ID__c, id, Trigger__c from Line_Item_Revision_Parent__c Where WF_ID__c =:LIRevisions ]; List <OpportunityLineItem > IOLineItem=[Select WF_ID__c, id from OpportunityLineItem where WF_ID__c =:LIRevisions ]; Map<String,Id> LIRPMap = new Map <String,ID> (); for (Line_Item_Revision_Parent__c LIP:LineItemParentList) { LIRPMAP.put(LIP.WF_ID__c,LIP.id); } Map<String,Id> IOLineItemMap = new Map <String,ID> (); for (OpportunityLineItem OLI:IOLineItem) { IOLineItemMap.put(OLI.WF_ID__c,OLI.id); } for (Line_Item_Revisions__c LIRadd : Trigger.new) { if (LIRPMAP.isEmpty () ) { Line_Item_Revision_Parent__c LIP2 = new Line_Item_Revision_Parent__c (); LIP2.WF_ID__c= LIRadd.WF_ID__c; LIP2.IO_Line_Item_Parent__c=IOLineItemMap.get(LIP2.WF_ID__c); LineItemParentstoCreate.add(LIP2); } if(!LIRPMAP.isEmpty()) { Line_Item_Revision_Parent__c LIP3 =LIRPMAP.get(LIRADD.WF_ID__c).id; LIP3.Trigger__c= LIRPMAP.get(LIP3.WF_ID__c)trigger__c+1; LineItemParentstoUpdate.add(LIP3); } } try{ update LineItemParentstoUpdate; insert LineItemParentstoCreate; }catch (System.Dmlexception e) { } }
The error occurs on this line 53
'Line_Item_Revision_Parent__c LIP3 =LIRPMAP.get(LIRADD.WF_ID__c).id;'
I thought I could use the collection of parent Id's to set the parent record I want to write to. Thanks in advance for your feedback.