You need to sign in to do that
Don't have an account?
Sourav P
salesforce how to update a field as per a related object field value
Hi,
I have a custom object " Transaction ( API Name : Quotation__c) " and a related object " Biz Validation" on it.
I want that, if there is any records exists in the " Biz validation" related object , the field " Biz Validation exists" value in the " Transaction" object should be "YES". can anyone plz suggest how to achieve this. I have the look up relationship between the two objects ( Biz valid being the child object). I have written the below trigger for it, although its not showing any errors while saviing, also its not working. Can anyone plz pont out where i gone wrong in the below trigger? Thanx
I have a custom object " Transaction ( API Name : Quotation__c) " and a related object " Biz Validation" on it.
I want that, if there is any records exists in the " Biz validation" related object , the field " Biz Validation exists" value in the " Transaction" object should be "YES". can anyone plz suggest how to achieve this. I have the look up relationship between the two objects ( Biz valid being the child object). I have written the below trigger for it, although its not showing any errors while saviing, also its not working. Can anyone plz pont out where i gone wrong in the below trigger? Thanx
trigger updateTrans on Biz_validations__c (after update) { Map<Id, Biz_validations__c> bizValidWithAuthLimit=new Map<Id, Biz_validations__c> (); for(Integer i=0; i<Trigger.new.size();i++){ if(Trigger.new[i].Authority_limit__c != null) { bizValidWithAuthLimit.put(Trigger.new[i].id,null); } } List<Quotation__c> updatedTrans=new List<Quotation__c>(); for (Quotation__c q : [SELECT id,Biz_Validation_Exists__c FROM Quotation__c WHERE id in :bizValidWithAuthLimit.keySet()]) { Biz_validations__c parentBizValid = bizValidWithAuthLimit.get(q.id); q.Biz_Validation_Exists__c= parentBizValid.Authority_limit__c; updatedTrans.add(q); } update updatedTrans ; }
Biz_validation object is related to which object?
Lets say if Biz_Validation is related to X obj.
I will write a workflow rule/Process builder on X obj to update the 'Biz Validation exists' field on Biz_validation.
Lets say look up field from X to Biz_validation is Biz_V__C
Steps for process builder:
1.Create workflow rule on X(When a record is created/edited).
2.Condition:Null check on look up field i.e Biz_V__C.
3.Action:Update records-Update the 'Biz Validation exists' on Biz_Validation.
Let us know if you have any issues.
Mark it as best answer if it works.
THanks.
All Answers
Biz_validation object is related to which object?
Lets say if Biz_Validation is related to X obj.
I will write a workflow rule/Process builder on X obj to update the 'Biz Validation exists' field on Biz_validation.
Lets say look up field from X to Biz_validation is Biz_V__C
Steps for process builder:
1.Create workflow rule on X(When a record is created/edited).
2.Condition:Null check on look up field i.e Biz_V__C.
3.Action:Update records-Update the 'Biz Validation exists' on Biz_Validation.
Let us know if you have any issues.
Mark it as best answer if it works.
THanks.