Problem with Default-Value-Function (depending from where called)

Martin68

Well-known member
Good Morning,

i am using the following function to identify the actual user by login-name und return the id-value of the entry in a separate table for users:

Code:
function dadabik_get_actual_userid(){
  
global $conn;
global $current_user;


$sql = "select id_Pruefer from tbl_Pruefer where Anmeldung_Windows = '$current_user'";
$res = execute_db($sql, $conn,0);


return $res->fetchColumn(0);
} // Ende Ermittlung aktuelle User-ID

Works well when working direct with the table from the menu, works not when calling from within a MAster-Detail-View...

Any idea what's going wrong?

Kind regards

Martin

----------------

Your current DaDaBIK version​

You are using DaDaBIK version 11.4-Elba enterprise, installed on 12.03.2022 (installation code: 0), the latest version of DaDaBIK is 11.4-Elba released on 28.02.2022

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enteprise to Platinum) please contact us.

System info​

PHP Version: 7.4.3

mysql version: 5.5.5-10.3.34-MariaDB-0ubuntu0.20.04.1

Web server: Apache/2.4.41 (Ubuntu)

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15
 

eugenio

Administrator
Staff member
Hello,
for security reasons it's better to use prepared statements (see documentation), but this is not the reason of your issue.

You didn't specify what triggers the execution of the function (a button?).
When you say it doesn't work what do you mean exactly, what happens?

Best,
 
Last edited:

Martin68

Well-known member
Hello,
for security reasons it's better to use prepared statements (see documentation), but this is not the reason of your issue.

You didn't specify what triggers the execution of the function (a button).
When you say it doesn't work what do you mean exactly, what happens?

Best,

Good Morning Eugenio,

thought I have had answered yesterday, but it seems I haven't clicked at "post reply" :)

The function is for a default-value for my colleagues; it uses the username to identify the actual worker and presume this for the foreign key to the "worker-table"...

Generally it works fine when called from a "pagelink", it returns an empty field just when called for entering details in a master-detail-situation (tested with the same table!).

Kind regards

Martin
 

eugenio

Administrator
Staff member
Hello,
sorry the fact the function was used for a default-value was actually implicit in your subject, probably I didn't read the subject carefully.

So basically when you are in a details page of a master/details form the function doesn't work. Questions:
1) Same behavior both for insert and update forms?
2) Can you check if $current_user is empty in that case? (You said the function returns an empty field, but I am not sure if $current_user is empty or the result of the query is).

Best,
 

Martin68

Well-known member
So basically when you are in a details page of a master/details form the function doesn't work. Questions:
1) Same behavior both for insert and update forms?
2) Can you check if $current_user is empty in that case? (You said the function returns an empty field, but I am not sure if $current_user is empty or the result of the query is).
Sorry for my late reply, busy season and implementing a database is a after-work-action ...

Unfortunately I am no real coder and have hat some technical problems getting out the value of $current_user .. first exploration of debugging php code isn't real fun....

With the help of JS Console.log it seems that the value is correct ... will check this later ..

Kind regards

Martin
-------------

Just tested what happens when returning fixed value, that should have worked without $current_user and even without my select ;-)

Didn't return anything, which leads to my supposition that the function isn't called when entering as a detail-entry in a master-detail-relation.

Is it a bug or a feature ? :)


Kind regards

Martin
 
Last edited:
Top