Cannot read anymore values of fields of type "Document (File Name)" in forms apps

I cannot read anymore the value of any field of type “Document (File Name)” from events or buttons in forms apps

I don’t know exactly after which version update, I’m now on SC 9.6.007.

I just tried to create a new form app from scratch with no changes after creation and no added code at all in any event.

I added only a PHP button and an AJAX button, both with just the code to read and display the value of the filenames fields for testing.

Initially I can read the values (the filenames fields are created automatically in the APP as Text fields).

Then I changed those fields from Text to “Document (File Name)” and the buttons now cannot read the values anymore and return empty values!

Actually it’s more complex.

Buttons can’t read the values of the “Document (File Name)” fields.

Events sometimes work.

This is the code that will always return an empty value ($v) when run in a AJAX button

$v = {doc_file_name_field};
sc_ajax_message("field value: '$v'");

The same code, in the onBeforeUpdate event will show the actual value of the field only the first time the form is loaded (in my test I opened a prepopulated record) and the save button is pressed.

Any further pressing of the the save button will run the event but the output of the field value is blank.

I tested it without chaging any values in any fields in the form: I just pressed the save button after the form was loaded and then tried again pressing the save button.

The same happens with image filename

@javi

I didn’t test with code in buttons anymore, but for code in events it seems that the issue is only after saving the form (users press the save button): from that moment on the code is not able to get the values of those fields.

As a workaround, I’m forcing a reload of the form with these two lines of code at the end of the onAfterUpdate event (“id_field” must be changed to the table id field name)

sc_commit_trans();
sc_redir($this->Ini->nm_cod_apl , id_field={id_field});

In this way, no matter how many times the form is saved (save button pressed) by the user, without closing it, the form will always be as just loaded and the code will work

1 Like

Thank you.
you are very kind to share your solution.

I will test it.
Have a nice day