0

Given:

  • A class named B.
  • 2 persistent records of class B, id = {"B1", "B2"}.
  • 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.

matmat
  • 85
  • 9

1 Answers1

2

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