+ Start a Discussion
ThomasmThomasm 

Initial term of field of expression must be a concrete object

I am looking for some help on a trigger to update a field.  I have 3 custom objects (job, Employee, and Employee form). the job is the master to the employee and the employee is the master to the employee form.  I have a number field called hats on the job object and when an employee form is created i want to use the quantity field to update the hat field.

So far i have the following but i am getting the error "Initial term of field of expression must be a concrete object".


trigger updateHats on Employee_Forms__c (before insert) {
   set<id> jobids=new set<id>();  
   map<id,jobs__c> jobsmap=new map<id,jobs__c>([select id, hats__C from jobs__c where id=:jobids]);
   //List<Jobs__C>Jobs=new list<jobs__c>();
    For(employee_forms__C b:Trigger.new)
        if(b.Uniform_Type__C=='Hat')
    {
        jobsmap.hats__C= jobsmap.hats__C - b.Quantity__C;
    }
        }


 
 
 
 
 
on the employee object I have

label: Job      API Name: Job__C  Data Type: Master-Detail(Job)

and the employee_Forms__C i have

Label: Employee    API Name:  Employee__C  Data Type:  Master-Detail(Employee)


I think its because the job and the employee form object are not directly related but i am not sure and if i was sure i am not sure how to go about fixing it.  

Any help i would appreciate 
 
Shrikant BagalShrikant Bagal
Hello ,

at Line 
jobsmap.hats__C= jobsmap.hats__C - b.Quantity__C;

you are trying to access map value through dot operator.

it should be jobsmap.get(job.id).hats__c

if its resolved your issue,please mark as best answer so it will help to other who will serve same problem.
​Thanks! 

 
ABHIKSARKARABHIKSARKAR
you are still trying to access the map directly using dot operator on the right .