Hello All,
I have a question / issue regarding the calling list.FindOref(<object from indexOpen call>)
Here is a simple way to reproduce the issue:
2 classes: Utility.contacttypes and Utility.person
*************************
Class Utility.contacttypes Extends %Persistent
{
Property description As %Library.String(TRUNCATE = 1);
/// Index for property description
Index descriptionIndex On description [ Unique ];
}*************************
Class Utility.person Extends %Persistent
{
Property types As list Of Utility.contacttypes;
/// Date Setup to recreate an error
ClassMethod DataSetup()
{
Set ref=##class(Utility.contacttypes).%New()
Set ref.description="Shipping"
Do ref.%Save()
Set ref=##class(Utility.contacttypes).%New()
Set ref.description="Billing"
Do ref.%Save()
Set tPerson = ##class(Utility.person).%New()
Do tPerson.types.Clear()
Set aryContacts(1)=""
Set aryContacts(2)=""
Set id=""
For
{ Set id=$o(aryContacts(id))
Quit:id=""
Do tPerson.types.InsertObjectId(id)
}
Do tPerson.%Save()
Write !,"Created a record"
Quit 1
}
/// Reproducing the issue - calling list.FindOref(<object from indexOpen call>) first time returns null!!!
ClassMethod Problem()
{
Set tPerson = ##class(Utility.person).%OpenId(1)
For i=1:1:2 {
If (tPerson.types.FindOref(##class(Utility.contacttypes).descriptionIndexOpen("Billing"))) {
Write !,"Run Number:"_i_" - Found it ok"
} else {
Write !,"Run Number:"_i_" - ERROR!, I did not find it!"
}
}
Close tPerson
Quit 1
}
}

