Hi,
need help again with n:m Object - this time with Delete:
I create my n:m Class Objects by this code (Class Method Add called from a
CSP Page):
Class EMEM.CompanyInterest Extends (%Persistent, %Populate, %XML.Adaptor)
[ ClassType = persistent, ProcedureBlock ]
{
Relationship Companies As EMEM.Company [ Cardinality = one, Inverse =
Mandators ];
Relationship Mandators As EMEM.Mandator [ Cardinality = one, Inverse =
Companies ];
Index CompaniesIndex On Companies;
Index MandatorsIndex On Mandators;
ClassMethod Remove(Id As %String)
{
set sc = ..%Delete(Id)
quit sc
}
ClassMethod Add(MandatorId As %String, CompanyId As %String)
{
set obj = ..%New()
set Mandator = ##class(EMEM.Mandator).%OpenId(MandatorId)
set Company = ##class(EMEM.Company).%OpenId(CompanyId)
set obj.Mandators = Mandator
set obj.Companies = Company
set sc = obj.%Save()
quit sc
}
On Deleting it calling Class Method Remove I get this Error Message (in the
Terminal):
set sc = ##class(EMEM.CompanyInterest).Remove(750)
%Delete(oid,concurrency) public { Set
oid=$get(oid),concurrency=$get(concurrency
,-1) Quit:oid="" $$Error^%apiOBJ(5813) Set id=$lg(oid) Quit:id=""
$$Error^%apiOB
^
J(5812)
<LIST>%Delete^EMEM.CompanyInterest.1
First I thought I would have to set the other Relations in the Add Method
manually,
but they was created:
set obj= ##class(EMEM.CompanyInterest).%OpenId(750)
EMEM 3e1>w obj
[EMAIL PROTECTED]
EMEM 3e1>w obj.Mandators
[EMAIL PROTECTED]
EMEM 3e1>w obj.Mandators.%Id()
3520
EMEM 3e1>w obj.Mandators.Companies
[EMAIL PROTECTED]
EMEM 3e1>w obj.Mandators.Companies.Count()
7
EMEM 3e1>w obj.Companies.Mandators.Count()
2
EMEM 3e1>
I can not understand the Error Message - what does it mean:
$$Error^%apiOBJ(5813) ... 5813 is not an Id as I thought first ???
whats wrong here ?
what List is this: <LIST>%Delete^EMEM.CompanyInterest.1 ???
brg
werner