function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim MontgomeryJim Montgomery 

Getting error Initial term of field expression must be a concrete SObject: Map<Id,Apttus_Proposal__Proposal__C>

Here is my code.
trigger TLIYear1Rollup on Template_Line_item__c (after insert, after update) {

    Map<ID, Apttus_Proposal__Proposal__c> parentProposal = new Map<ID, Apttus_Proposal__Proposal__c>();
    List<Id> listIds = new List<Id>();
    List<Id> LineItems = new List<Id>();

    for (Template_Line_item__c childObj : Trigger.new) {
        listIds.add(childObj.Quote_Proposal__c);
        LineItems.add(childObj.Id);
    }
  
    parentProposal = new Map<Id, Apttus_Proposal__Proposal__c>([SELECT id,TLI_Net_Price_Rollup__c ,(Select id, Net_Price__c, Year_2_Price_Form__c, Year_3_Price_Form__C, Year_4_Price_Form__c, Year_5_Price_Form__C from Template_Line_Items__r where net_price__c > 0) FROM Apttus_Proposal__Proposal__c WHERE ID IN :listIds]);
    
    for (Template_Line_item__c TemplateLineItem: Trigger.new){
         Apttus_Proposal__Proposal__c myParentProposal = parentProposal.get(TemplateLineItem.Quote_Proposal__c);
        if(parentProposal.containsKey(TemplateLineItem.Quote_Proposal__c) && parentProposal.get(TemplateLineItem.Quote_Proposal__c).Template_Line_Items__r.size() > 0)
        {
            myParentProposal.TLI_Net_Price_Rollup__c = SUM(ParentProposal.Net_Price__C);
        }
        else
        {
            myParentProposal.TLI_Net_Price_Rollup__c = 0 ;
        }
    }
    update parentProposal.values();
 }

 
Best Answer chosen by Jim Montgomery
Mohan_ShanmugamMohan_Shanmugam
Ok Jim, that is not possible at line 18. replace with below code and the price should get updated in proposal.

Map<ID, Apttus_Proposal__Proposal__c> parentProposal = new Map<ID, Apttus_Proposal__Proposal__c>();
    List<Id> listIds = new List<Id>();
    List<Id> LineItems = new List<Id>();

    for (Template_Line_item__c childObj : Trigger.new) {
        listIds.add(childObj.Quote_Proposal__c);
        LineItems.add(childObj.Id);
    }
  
    parentProposal = new Map<Id, Apttus_Proposal__Proposal__c>([SELECT id,TLI_Net_Price_Rollup__c ,(Select id, Net_Price__c, Year_2_Price_Form__c, Year_3_Price_Form__C, Year_4_Price_Form__c, Year_5_Price_Form__C from Template_Line_Items__r where net_price__c > 0) FROM Apttus_Proposal__Proposal__c WHERE ID IN :listIds]);
    
    for (Template_Line_item__c TemplateLineItem: Trigger.new){
         Apttus_Proposal__Proposal__c myParentProposal = parentProposal.get(TemplateLineItem.Quote_Proposal__c);
        if(parentProposal.containsKey(TemplateLineItem.Quote_Proposal__c) && parentProposal.get(TemplateLineItem.Quote_Proposal__c).Template_Line_Items__r.size() > 0)
        {
            //myParentProposal.TLI_Net_Price_Rollup__c = SUM(ParentProposal.Net_Price__C);
            myParentProposal.TLI_Net_Price_Rollup__c=0;
            for(Template_Line_Items__c tempLineItem : parentProposal.get(TemplateLineItem.Quote_Proposal__c).Template_Line_Items__r){
                
                myParentProposal.TLI_Net_Price_Rollup__c=myParentProposal.TLI_Net_Price_Rollup__c+tempLineItem.Net_Price__C;
            }
        }
        else
        {
            myParentProposal.TLI_Net_Price_Rollup__c = 0 ;
        }
    }
    update parentProposal.values();
 }

All Answers

Mohan_ShanmugamMohan_Shanmugam

Hi Jim,

Can you tell me the line number at which the error is thrown.
Jim MontgomeryJim Montgomery
Line 18 myParentProposal.TLI_Net_Price_Rollup__c = SUM(ParentProposal.Net_Price__C); Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com
Mohan_ShanmugamMohan_Shanmugam
Ok Jim, that is not possible at line 18. replace with below code and the price should get updated in proposal.

Map<ID, Apttus_Proposal__Proposal__c> parentProposal = new Map<ID, Apttus_Proposal__Proposal__c>();
    List<Id> listIds = new List<Id>();
    List<Id> LineItems = new List<Id>();

    for (Template_Line_item__c childObj : Trigger.new) {
        listIds.add(childObj.Quote_Proposal__c);
        LineItems.add(childObj.Id);
    }
  
    parentProposal = new Map<Id, Apttus_Proposal__Proposal__c>([SELECT id,TLI_Net_Price_Rollup__c ,(Select id, Net_Price__c, Year_2_Price_Form__c, Year_3_Price_Form__C, Year_4_Price_Form__c, Year_5_Price_Form__C from Template_Line_Items__r where net_price__c > 0) FROM Apttus_Proposal__Proposal__c WHERE ID IN :listIds]);
    
    for (Template_Line_item__c TemplateLineItem: Trigger.new){
         Apttus_Proposal__Proposal__c myParentProposal = parentProposal.get(TemplateLineItem.Quote_Proposal__c);
        if(parentProposal.containsKey(TemplateLineItem.Quote_Proposal__c) && parentProposal.get(TemplateLineItem.Quote_Proposal__c).Template_Line_Items__r.size() > 0)
        {
            //myParentProposal.TLI_Net_Price_Rollup__c = SUM(ParentProposal.Net_Price__C);
            myParentProposal.TLI_Net_Price_Rollup__c=0;
            for(Template_Line_Items__c tempLineItem : parentProposal.get(TemplateLineItem.Quote_Proposal__c).Template_Line_Items__r){
                
                myParentProposal.TLI_Net_Price_Rollup__c=myParentProposal.TLI_Net_Price_Rollup__c+tempLineItem.Net_Price__C;
            }
        }
        else
        {
            myParentProposal.TLI_Net_Price_Rollup__c = 0 ;
        }
    }
    update parentProposal.values();
 }
This was selected as the best answer
Jim MontgomeryJim Montgomery
Thank you!!! Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com