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
Peter CowenPeter Cowen 

how to match fields

i have two objects with bug number on 
Service Request 

I would like to create a trigger so that once a case is updated with the bug number and the bug number is in Service Request it populates the Service Request field on case. 

I have no idea how I can set the trigger so if a case is created or updated with a bug number it looks at service request to see if a active service request has that bug number and it will need to do the same when a service request is created it searchs the cases for that bug number and fills in the service request field. 
Nirmala  KuchiNirmala Kuchi
Hi Peter,

We need to write two triggers here: one on Case and other on Service Request.

Case trigger: 

if(trigger.isBefore && trigger.isUpdate){
    If(oldCase.bugNumber == null and newCase.bugNumber != null){
        write code to query service request where bugNumber = newCase.bugNumber;
        if record is found, then populates the Service Request field on case. 

Same logic is applicable for Service trigger too.