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
koti91koti91 

Help on trigger

Hello I need to help on writing some trigger logic. Here is the requirement:

 

I had two objects objA and obj B.

 

objB has a Master-Detail Relationship to objA.

 

on objB i had a custom field called: ID_Number__c

on objA i had a custom field called: objB_ID_Numbers__c.

 

I need to write a trigger on objB...when ever a record is inserted or updated...or deleted ....then what should happen is...ID_Number__c  field on obj B needs to be copied to objB_ID_Numbers__c on objA.

 

Example: when record 1 is inserted with ID_Number__c as 123  to objB then objA.objB_ID_Numbers__c should have the value 123.

when record 2 is inserted with ID_Number__c as 456 to objB then objA.objB_ID_Numbers__c should have the value 123;456

when record1 is deleted then objA.objB_ID_Numbers__c should have 456.

 

Each time record is inserted or updated or deleted then objA.objB_ID_Numbers__c field should be calculated processing all records(i.e when record 1 is inserted we have 123, when record 2 is inserted then we will be having 123;456 , when second time record is inserted objA.objB_ID_Numbers__c field should again calculate from the first taking record 1 in to consideration).

 

can any one help in writing this trigger. its very urgent....