Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Object Access Condition causes Internal Server Error. [500] Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
IzzyBok
Posts: 6
Joined: Sat Aug 20, 2022 2:25 am
Has thanked: 3 times

Object Access Condition causes Internal Server Error. [500]

Unread post by IzzyBok »

Hi,
I'm trying to use new feature: Object Access Management with SQL Queries

viewtopic.php?p=29173&hilit=Object+Acce ... ion#p29173
object_properties.png
but this causes an Internal Server Error. [500]
error_500.png
Аny ideas on this?
Thank you in advance for the answer
You do not have the required permissions to view the files attached to this post.
IzzyBok
Posts: 6
Joined: Sat Aug 20, 2022 2:25 am
Has thanked: 3 times

Re: Object Access Condition causes Internal Server Error. [500]

Unread post by IzzyBok »

Hi,
This is my server log

[Mon Jan 15 15:04:52.399706 2024] [php:error] [pid 644] [client 31.200.229.186:51758] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function nuRunQueryString(), 1 passed in /var/www/html/DevDB/core/nuform.php on line 631 and exactly 2 expected in /var/www/html/DevDB/core/nudatabase.php:181\nStack trace:\n#0 /var/www/html/DevDB/core/nuform.php(631): nuRunQueryString()\n#1 /var/www/html/DevDB/core/nuform.php(611): nuGetObjectAccess()\n#2 /var/www/html/DevDB/core/nuform.php(185): nuDefaultObject()\n#3 /var/www/html/DevDB/core/nuapi.php(92): nuGetFormObject()\n#4 {main}\n thrown in /var/www/html/DevDB/core/nudatabase.php on line 181, referer: http://1xx.x.xx.x/DevDB/index.php

My version info
Database: Ubuntu 20.04 10.3.38-MariaDB-0ubuntu0.20.04.1
PHP: 8.2.2
nuBuilder DB: V.4.5-2023.10.05.01
nuBuilder Files: V.4.5-2023.10.05.01

Thank you for any help
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Object Access Condition causes Internal Server Error. [500]

Unread post by kev1n »

Replace the function nuGetObjectAccess() in nuform.php with this one:

Code: Select all

function nuGetObjectAccess($access, $condition) {

	if ($access == 9 && !empty(trim($condition))) {

		$sql	= nuReplaceHashVariables($condition);
		$stmt	= nuRunQueryString($sql, $condition);
		if (db_num_rows($stmt) == 1) {
			$value = db_fetch_row($stmt)[0];
			return $value;
		} else {
			return 0; 	// read/visible
		}

	} else {
		return $access;
	}

}
IzzyBok
Posts: 6
Joined: Sat Aug 20, 2022 2:25 am
Has thanked: 3 times

Re: Object Access Condition causes Internal Server Error. [500]

Unread post by IzzyBok »

Thanks a lot Kev1n!
Everything works fine, but if the object access condition refers to the display object, the condition is not fulfilled immediately after opening the form.
Then the page needs to be refreshed again in order for the condition to be fulfilled.
I want to hide Subform object depending on the value of the Display object on the same form.
I use the following condition in the subform object properties

SELECT IF('#sta_form_display#' = '1', 2, 0)

where 'sta_form_display' is the display object with following SQL

SELECT sta_form FROM status_contragent
WHERE status_contragent_id = '#con_status_id#'

Before I used the following JS code to hide subform object

if (nuGetValue('sta_form_display') == '1') {
nuHide('contragent_sf');
}

and no additional page refresh was required
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Object Access Condition causes Internal Server Error. [500]

Unread post by kev1n »

It could be that the display object comes later in the tab order and the value is only available after the subform has been "loaded". Theoretically, you could also enter the SQL of the display object in the condition field.
IzzyBok
Posts: 6
Joined: Sat Aug 20, 2022 2:25 am
Has thanked: 3 times

Re: Object Access Condition causes Internal Server Error. [500]

Unread post by IzzyBok »

Hi Kev1n, thank you so much for your reply.
I changed objects in the tab order with no result.
I entered the SQL of the display object in the condition field and problem was solved.
Thanks once more.
Post Reply