0

I am calling another class from my trigger and it works in sandbox, but when I try to validate my deployment (I am using a change set to deploy) in prod, it says "variable does not exist: JobServiceAPI" I'm confused on why the error does not happen in sandbox and everything works fine.

trigger JobCreatedTrigger on Job_Created__e (after insert) {

  for( Job_Created__e event : Trigger.New) {
      JobServiceAPI.createJob(event.job_id__c, event.job_title__c);
  }

}

Here is the simplified apex class:

public class JobServiceAPI {

   public JobServiceAPI () {
   }

   public static void createJob(string jobId, string jobTitle) {
   }
}
4
  • Sounds like your changeset (or package.xml) isn't including your JobServiceAPI class. I'd double check to make sure that it's included in your deployment.
    – Derek F
    Jun 7, 2019 at 23:47
  • 2
    You need to read all the errors from deployment. It might be that a field or object doesn't exist, or a custom label, or something else. If JobServiceAPI fails to compile, it will cause cascading errors.
    – sfdcfox
    Jun 7, 2019 at 23:52
  • Please check JobServiceAPI is available in prod and your profile have access to this apex or try creating job from Anonymous window. Jun 8, 2019 at 0:02
  • I was missing a couple of fields as you mentioned @sfdcfox, once I added the fields the errors went away Jun 8, 2019 at 0:21

2 Answers 2

2

When deploying via a change set, dependencies are not automatically checked. It is important to make sure you're not missing any fields, objects, labels, etc that are dependencies for the classes to deploy, otherwise they will fail to compile, and this can cause cascading errors. It's important that you read all the deployment errors to make sure you're not missing any dependencies.

1

To start with, the createJob method is being called as though it were static, when it is in fact an instance method.

There won't be different compilers on the sandbox and the prod org, so they can't be identical.

1
  • You are right @barrick, the method is declared as static, I have updated my code, but still the issue persists Jun 7, 2019 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .