BUG: empty fields return the string "undefined" when checked on ajax events

Checking for a integer key field named “id_prj” on a form app.

On a (not yet inserted) new record on the onLoad event, this code:

$m = empty({id_prj}) 
		? "empty id" 
		: "id_prj = '" . {id_prj} . "'";
echo $m;
sc_alert($m);

will show, correctly, this:

empty id


But if the same code is run from an an Ajax event of one of the form fields, still on a not inserted new record, it will show:

id_prj = ‘undefined’

I.e. the empty integer field has the string “undefined” as its value.
Why?

Not sure, but i think this was not the case in past SC versions (no idea when this behavior was introduced).

This is definitely a dangerous bug for all code run on ajax events of form fields.

@robydago,

After conducting several tests, we identified distinct behavior between events and have already reported the issue to the responsible team for correction.

As soon as the fix is ​​released, we will provide feedback through this topic.

Best regards!

I’m sorry about that. I don’t want to hate on SC, but I have to be honest: SC used to have quite a few bugs, and that’s one of the main reasons I moved away from it and started working with frameworks instead.

With frameworks, I have much more control and can build what I need without being blocked by internal bugs I can’t fix myself, or having to wait for a future release to resolve them.

1 Like