Is the data binding default function meant to work the same for both SC (in my case PHP) and client-side?
I’m finding that the behaviour for empty strings (not NULL) is different:
Server Connect treats an empty string as something that would trigger the default value however, client-side formatter seems to leave it as an empty string.
e.g. imagine a SC returns two values
firstname = 'John'
preferredname = 'Johnny'
I use
preferredname.default(firstname)
to show the preferred name if present, otherwise the first name.
if it were:
firstname = 'John'
preferredname = ''
(not preferredname = null
)
and
preferredname.default(firstname)
it would display the blank string without triggering the default value
however the same thing in SC does trigger the default value.
To demonstrate:
I set a value on SC
Returns values:
In a table cell I show the results of Server Connect default, Client-Side default, and a workaround using ternary statement looking at the length of the string:
<td
dmx-html="pupsurname.uppercase()+',<br>
SC Def:'+prefname_def.titlecase()+',<br>
C-S Def:'+pupprefname.default(pupfname).titlecase()+',<br>
Ternary:'+(pupprefname.length() > 0 ? pupprefname : pupfname).titlecase()">
</td>
Cell Result:
Last updated: