10
Views
2
Comments
[Reactive] how to pass Null input to Javascript as undefined
Application Type
Reactive
Platform Version
11.10.0 (Build 22422)

I have a client action with multiple inputs and a JS "action", I want some of the inputs to be optional, but, when passing them as JS inputs, for instance a integer would pass 0 as NullIdentifier(). What I want is this input parameter to be interpreted as undefined by JS instead of 0.

Is there any way to do this?

Rank: #238

Hi,

If you need to differentiate between null and zero/empty/true/false integer/text/date/boolean values, I'd double up on inputs to JS action:
- input1 (int)
- input2 (int)

would then become:
- input1 (int)
- input1_hasvalue (bool)
- input2 (int)
- input2_hasvalue (bool)

Which is basically introducing a concept for "nullable datatype". Inside your JS action (where a concept for null exists) , you can then set/override variables based on this "doubled" _hasvalue input. It's extra logic, but necessary with the platform. 

Whenever there are lots of variables, I'd also probably lean towards structures and json serialization / deserialization so the interfaces between OS and JS code stay a bit cleaner.