You need to sign in to do that
Don't have an account?
manjunath vivek
Not succeeded in writing trigger to update the field of master object when child record is created.
I have two custom objects Review__c and Job_application__c, they have master-detail relationship,Job_application__c is a master object and Review__c is a child object.Iam trying to write a trigger to update thee field status as new for every new review__C record,
Iam not succeeded writing trigger
below is the code I tried
trigger child on Review__c(before insert){
List<id> parent=New list<id>();
For(Review__c R:trigger.new){
Parent.add(R.parentid);
}
for(Review__C R :[Select id,Total_Rating__c from Job_application__c where id IN: parentid]){
R.satus__c='0';
}
}
Can some one help me on this?
Iam not succeeded writing trigger
below is the code I tried
trigger child on Review__c(before insert){
List<id> parent=New list<id>();
For(Review__c R:trigger.new){
Parent.add(R.parentid);
}
for(Review__C R :[Select id,Total_Rating__c from Job_application__c where id IN: parentid]){
R.satus__c='0';
}
}
Can some one help me on this?
i think you want to update parent object satus__c field with 0 when ever a new child record is created.
if thats the case try this trigger:-
Thanks
Anil.B
All Answers
i think you want to update parent object satus__c field with 0 when ever a new child record is created.
if thats the case try this trigger:-
Thanks
Anil.B
Thanks for reply,when I try this code , Iam getting the error message
Error: Compile Error: Variable does not exist: parentid at line 15 column 103
put the parent field (job_application__c something like this on child object)in the parentid.
There will be a realtion field which contains parent id on child object ,put that field in place of parent id.
Thanks
Anil.B
Final working code is as below