Question
· Apr 26, 2018

Keep getting METHOD DOES NOT EXIST

I am trying to create a list of id's which are of type integer. I have created a class like below and then I am trying to call the class from a BPL to first initialize the list. In the BPL, I have an assign action that is using set and a context variable setup to hold the list data. The property is using the class I have created, ##class(MSI.IN835.EOBList).%New(). I keep getting an error back saying the method does not exist. Why does it not like the %new method? I am new to cache object script, so if their is a better way to do this, I am open to that as well.

Class MSI.IN835.EOBList Extends %RegisteredObject
{

Property EOBList As list Of %Integer;

Storage Default
{
<Data name="EOBListDefaultData">
<Subscript>"EOBList"</Subscript>
<Value name="1">
<Value>EOBList</Value>
</Value>
</Data>
<DefaultData>EOBListDefaultData</DefaultData>
<Type>%Library.CacheStorage</Type>
}

}

Discussion (9)0
Log in or sign up to continue

The Add EOB's to list is disabled right now. The initialization is below.

The first piece is where I get the EOBID back and it's assigned to tEOBID.

<response type='MSI.IN835.bo.CreateStageEOBin>
<assign property="context.tEOBIDvalue="callresponse.EOBIDaction="set" />
</response>
</call>
<trace name='EOBID' value='"EOB ID="_context.tEOBIDxpos='200' ypos='550' />

Here is where  the list is created.

<sequence name='Create EOB List' xpos='200' ypos='650' xend='200' yend='550' >
<trace name='1' value='"1"' xpos='200' ypos='250' />
<assign name="Init EOB List" property="context.tEOBListvalue="##class(MSI.IN835.EOBList).%New()action="set" xpos='200' ypos='350' />
<assign name="Add EOB's to List" property="statusvalue="context.tEOBList.Insert(context.tEOBID)action="set" xpos='200' ypos='450' disabled="true"/>
</sequence>

So, I would declare my context property(context.tEOBList) in the BPL like this: ##class(%Library.ListOfDataTypes).%New()? Because I have tried this as well, but I get a different error when doing that.

Invalid status code structure ("Cache error: <OBJECT DISPATCH>zS46+6^MSI.IN835.bp.IncomingWork6.Thread1.1 *Property 'tEOBList' in class 'MSI.IN835.bp.IncomingWork6.Context' is not MultiDimensional

It seems you have manually changed the class definition.

A normal RegisterdObject has no storage definition.
from <Type>%Library.CacheStorage</Type> i see it was a %Rersitent before.

Storage Default
{
<Data name="EOBListDefaultData">
<Subscript>"EOBList"</Subscript>
<Value name="1">
<Value>EOBList</Value>
</Value>
</Data>
<DefaultData>EOBListDefaultData</DefaultData>
<Type>%Library.CacheStorage</Type>
}

remove Storage and recompile.

Okay, thanks for updating.  That error didn't seem to make sense based on what you showed before.

This very simple BPL might help you see how to declare and use a List:

<process language='objectscript' request='Ens.Request' response='Ens.Response' height='2000' width='2000' >
<context>
       <property name='MyList' type='%Integer' collection='list' instantiate='0' />
</context>
<sequence xend='227' yend='451' >
        <assign name="Append 1" property="context.MyListvalue="1action="append" xpos='278' ypos='291' />
</sequence>
</process>

Note that I don't need to initialize my list property.  That will happen automatically.

Also note that I'm using action='append'.  That will insert the new value to the end of the list.  It corresponds to this in COS:

do context.MyList.Insert(1)

BPL also has action='insert', but that inserts into a specific location.  It's equivalent to InsertAt for lists, or SetAt for arrays.

Probably unrelated, but you most likely do want MSI.IN835.EOBList to have storage.

The reason is that if your BPL suspends for any reason (such as a Call) between the time you set and use that data, you'll lose whatever values you were trying to save.  That's because the job that's executing your BPL will %Save the Context object and go work on another task while it's waiting.  When the Call returns it will reload the Context object and resume work.  If you extend %RegisteredObject your context property won't survive the save/reload.

It might be tempting to ignore that if you're not currently doing any intervening Calls, but things tend to change over time, so doing it now could prevent a hard-to-find bug later.

%SerialObject is probably better that %Persistent for this because that way you won't have to implement your own purge of old objects.

Or, if you only need to store a list of integers, you could just declare your context property as that and skip the custom wrapper class.