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
Alex MyersAlex Myers 

Invalid Type error on trigger calling class & method

I'm trying to write a trigger that calls a method for a specific set of records. I'm pretty new to Apex, so sorry if this is a dumb question! I'm getting a Compile Error: Invalid Type: ReversalUtils (which is my class) at line 15 column 27. The class I'm trying to call (ReversalUtils) isn't editable to me.

trigger testrev on Opportunity (after update) {

String datestr = '01/01/2011';
Date datestr2 = date.ValueOf(datestr);

Map<Id, Opportunity> oppsmap = new Map<Id, Opportunity>();

   //put them all in a list
   List<Opportunity> results = new List<Opportunity>();
 
   for (Opportunity o: [SELECT Id, cv__Posted__c, CloseDate 
                       FROM Opportunity
                       WHERE Id in :oppsmap.keySet()AND cv__Posted__c = true]) {
       
cv.ReversalUtils rs = new ReversalUtils();
rs.reverseGiftsWithErrorReporting(o);

       }}

Thank you!!
digamber.prasaddigamber.prasad
Hi Alex,

Is class ReversalUtils is part of some managed package?

Regards,
Digamber Prasad
Alex MyersAlex Myers
Yep - that's why I can't edit it.
digamber.prasaddigamber.prasad
Oh, in that case you have to use namespace before class name. Something like <namespaceName>__ReversalUtils();


Regards,
Digamber Prasad

Alex MyersAlex Myers
Hm- I'm still getting Error: Compile Error: Invalid type: cv__ReversalUtils at line 15 column 27 when I include the namespace (_ or __). Any other ideas?

And thank you!
digamber.prasaddigamber.prasad
(__) is fine. Do you have sys adming profile? If not could you please see if your profile has access to this class?

Regards,
Digamber Prasad
Alex MyersAlex Myers
Yes, I am a sys admin - I should have access to the class, unless it's restricted by the managed package? (Does that happen?)

Thanks!
digamber.prasaddigamber.prasad
If you are trying to access class of a managed package outside of it, then it got to be global class, as well as the methods also needs to be global. And if all is set well, then you have to use pacakageName.ClassName.MethodName() something like http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_namespace_prefix.htm

Regards,
Digamber Prasad
Alex MyersAlex Myers
The class is global, but the method is webservice static boolean. Will that work for me?


digamber.prasaddigamber.prasad
oh yes, that should be fine.

Regards,
Digamber Prasad
Alex MyersAlex Myers
I changed up the bottom part so I'm not instantiating the class, but it looks like the format in the link you sent over: 

cv.ReversalUtils.reverseGiftsWithErrorReporting(o);

and this time I'm getting a Compile Error: Method does not exist or incorrect signature: cv.ReversalUtils.reverseGiftsWithErrorReporting(SOBJECT:Opportunity)

What do you think? and thanks!
Vinit_KumarVinit_Kumar
Can you post the code of the Managed package method,it seems you are not passing correct arguements while calling that method !!
Alex MyersAlex Myers
Unfortunately I don't know if I have access - is it possible to write a trigger without it? Or if I did have access what would I need to look for?

Thank you!
Vinit_KumarVinit_Kumar
You should be passing the correct arguements which the method is expecting,then only you will be able to remove this error and your code will work.
Alex MyersAlex Myers
If I had access, how could I tell what the method is expecting? And thank you - I'm obviously really new to this.