Harshdeep Acharya · Mar 29, 2022

<METHOD DOES NOT EXIST> Error getting when call method from ClassMethod.

Hi Team,

I am getting the below error while calling Method from ClassMethod in the same cls file.

Please help me with this, So It would be very helpful for me.

ERROR <Ens>ErrException: <METHOD DOES NOT EXIST>zHL7ToFHIRService+13 ^FHIRConversion.FHIR.BusinessService.HL7ToFHIRService.1 *SendRequestSync,Ens.BusinessService -- logged as '-'
number - @'
Set tSC = ##class(Ens.BusinessService).SendRequestSync("HL7ToFHIRBusinessProcess",pInput,.tResponse)'
Harshdeep Acharya
Product version: IRIS 2021.1
0 173
Discussion (4)1
Log in or sign up to continue

calling Method from ClassMethod

This is the problem. A Method needs to be called in the context of an instantiated object. A ClassMethod by definition isn't associated with an instantiated object.

If it's necessary to do it this way, your ClassMethod could use %New() to instantiate an object and then call the Method on that object:

set myObj = ##class(My.Object.Class).%New()
set tSC=myObj.myMethod()

But, it looks like you're working with a Business Service class. For that, it isn't enough to simply use %New(). You need to use Ens.Director::CreateBusinessService to instantiate the object before calling the Method.

A thumbs up to Marc who explained the same method distinction I did, but went the extra mile to explain how to instantiate a business component (with doc link)!

SendRequestSync   is an object method that requires an object as the base.
##class(Ens.BusinessService).SendRequestSync(   works for ClassMethods only.
You need an object instance of Ens.BusinessService to call it.
might be a dirty workaround


You're trying to call a method like a class method. For a "method" you need to have an instance of the object to use the method, "class methods" can be called without an object reference.

See docs here:

Defining and Calling Methods