1

I have an Apex class in my Managed package that contains the standard methods that do most of the work in our application.

Here is a little snipped of the managed package code...

public with sharing class OrderService
{
public class OrderInfo
{
     public Id OrderID;
     public Date returnDate;
     public boolean Validated;
     public string ValidationMessage;                  
}
public static void ValidateCommitOrders(List<OrderInfo> OrderInfos)
{
    a bunch of code here
}
}

Now I am working in an Extension Org for a customer of that package and trying to write a test class that attempts to do one of those standard processes.

Here is a snippet of that test class code...

   OrderService.OrderInfo OrderInfo = new OrderService.OrderInfo();
   OrderInfo.OrderId = objOR1.Id;
   List<OrderService.OrderInfo> OrderInfos = new List<OrderService.OrderInfo>{OrderInfo};
   OrderService.ValidateCommitOrders(OrderInfos);
   System.assertequals(OrderInfo.Validated,FALSE);

And I am getting a compile error.

   Error: Compile Error: Invalid type: OrderService.OrderInfo at line 1,058 column 49

(line 1058 is the top line in the test code sample)

Is there a way to using Managed Package apex classes in an org where the package is installed?

Any assistance/direction y'all could provide would be greatly appreciated Angie

4

There are two things you are missing:

1: Global Methods

Your method needs to be declared as global so that it can be accessed from outside of the managed package. NB: Once a method has been marked as global and the package has been uploaded, you will not be able to remove that method or change its signature

2: Namespaces

You need to add the namespace of your managed package to reference components from it. e.g. abc.OrderService

| improve this answer | |
  • 1
    As an additional clarification, you can check the namespace prefix for your managed packages here: Setup -> Installed Packages -> Your Package Name -> Namespace Prefix field. – hlopetz Sep 30 '16 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.