dateFormat expression issue

Ign 7.7.0 (b2014071516) | 64-bit

I have an issue using dateFormat in a textbox.text field

Here is an example that you can reproduce

This works

dateFormat({[System]Client/System/CurrentDateTime},{[System]Client/System/CurrentDateTime.FormatString})

This does not

dateFormat(tag("[System]Client/System/CurrentDateTime"),{[System]Client/System/CurrentDateTime.FormatString})

Type mismatch, arg 0 error invalid type

But

tag("[System]Client/System/CurrentDateTime")

displays date text ok.

It appears the tag() returns the date value as a string. dateFormat() requires it to be a date.

Try dateFormat(toDate(tag("[System]Client/System/CurrentDateTime")),{[System]Client/System/CurrentDateTime.FormatString})

I also had to do a toStr on the formatstring.

Does this mean the tag call is returning the object repr rather than object.value? One would not expect to have to cast a string object.

My real example uses MES production model tags and this finally appears to work.

if (isNull(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time")),"",
dateFormat(toDate(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time")),
toStr(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time.FormatString"))))