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
ThomasmThomasm 

Trigger to update field on master-detail

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 a 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;
    }
        }


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
can you please post the relationship field of Job on employee  Object and 
relationship field name of employee_forms__C  and Employee

 
ThomasmThomasm
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)