Ruslan K · Mar 11, 2021


Is there any reason that property method DisplayToLogical() is not calling before object saving?

I have such situation and do not know how it is possible

Product version: Caché 2018.1
0 215
Discussion (3)2
Log in or sign up to continue

DisplayToLogical converts external input to internal format.
if you have an object everything is internal already.
what would you expect to convert?

DisplayToLogical is just not involved in that process.
You may eventually look for LogicalToStorage  -  [a rare case]

Hello Ruslan, 

You are correct, DisplayToLogical() is not called automatically when saving an object. When you are manipulating an object using ObjectScript, the assumption is that the value you are dealing with is already a logical value. If you need to convert from a display value, you can do so explicitly. For instance, if you have a the following class:

Class Test.MyClass Extends %Persistent
Property MyDate As %Date;

You can convert from display to internal using either of the following:

set myobj = ##class(Test.MyClass).%New()
set myobj.MyDate = ##class(%Date).DisplayToLogical(value)
set myobj.MyDate = ##class(Test.MyClass).MyDateDisplayToLogical(value)

Thanks Sean,

I got it.