Question
Ruslan K · Mar 11, 2021

DisplayToLogical

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
00
2 0 3 69
Log in or sign up to continue

Replies

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.