Reputation: 85
Given:
A class named A:
class A Extends %Persistent
{
Property rB As B;
ForeignKey FKB(rB) References B();
}
An instance of class A, named objA, with objA.rB = "B3" (which is an invalid value because B has no "B3" persistent record)
I want that:
When objA is going to be saved (objA.%Save()), substitute with an empty string the rB invalid value and save it.
So far:
I have tried to make the substitution using callback methods ( %OnBeforeSave), but it seems that %ValidateObject is being called before.
Is there a way of doing value changes before %ValidateObject using callback methods?
Thanks in advance.
Upvotes: 0
Views: 498
Reputation: 21
You can modify objects in callback method %OnAddToSaveSet: http://docs.intersystems.com/cache201511/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_callbacks#GOBJ_cb_onaddtosaveset
Upvotes: 2