Auto-Update Value - Warning: Undefined variable $rsnew

i haveWarning: Undefined variable $rsnew in C:\xampp\htdocs\pruebas\models\Remates.php on line 246Warning: Undefined variable $rsnew in C:\xampp\htdocs\pruebas\models\Remates.php on line 449Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\pruebas\src\userfn.php on line 514
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1This is my code

function BuscoUltimoSerie($rsnew) {
				$hostname_amercado = isset($_SERVER['DB_HOSTNAME']) ? $_SERVER['DB_HOSTNAME'] : "vm3.adrianmercado.com.ar";
		$database_amercado = isset($_SERVER['DB_DATABASE']) ? $_SERVER['DB_DATABASE'] : "am_test";
		$username_amercado = isset($_SERVER['DB_USER']) ? $_SERVER['DB_USER'] : "am_test_user";
		$password_amercado = isset($_SERVER['DB_PASSWORD']) ? $_SERVER['DB_PASSWORD'] : "IV20pRY3VkAcIcs";

		// LEO LA TABLA SERIES
	$amercado = mysqli_connect($hostname_amercado, $username_amercado, $password_amercado) or trigger_error(mysqli_error($amercado),E_USER_ERROR);
		// BUSCO LOS CAMPOS NECESARIOS PARA VALIDAR
		$serie    = $rsnew['serie'];  

		// LEO LA TABLA SERIES
	mysqli_select_db($amercado, $database_amercado);
	$query = sprintf("SELECT * FROM series WHERE series.codnum = $serie"); 
	$Result = mysqli_query($amercado, $query) or die(mysqli_error($amercado));
	$row_Result = mysqli_fetch_assoc($Result);   
	$nroact = $row_Result['nroact'];
	return $nroact + 1;
}

You did not post how you pass $rsnew to your own function, you need to post lines near 246 and 449 in Remates.php, and lines near 514 in userfn.php. Make sure you pass $rsnew correctly.

my code

// ncomp
        $this->ncomp = new DbField(
            $this, // Table
            'x_ncomp', // Variable name
            'ncomp', // Name
            '`ncomp`', // Expression
            '`ncomp`', // Basic search expression
            3, // Type
            11, // Size
            -1, // Date/Time format
            false, // Is upload field
            '`ncomp`', // Virtual expression
            false, // Is virtual
            false, // Force selection
            false, // Is Virtual search
            'FORMATTED TEXT', // View Tag
            'TEXT' // Edit Tag
        );
        $this->ncomp->addMethod("getAutoUpdateValue", fn() => BuscoNuevoRemate($rsnew));
        $this->ncomp->InputTextType = "text";
        $this->ncomp->Raw = true;
        $this->ncomp->IsForeignKey = true; // Foreign key field
        $this->ncomp->Nullable = false; // NOT NULL field
        $this->ncomp->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
        $this->ncomp->SearchOperators = ["=", "<>", "IN", "NOT IN", "<", "<=", ">", ">=", "BETWEEN", "NOT BETWEEN"];
        $this->Fields['ncomp'] = &$this->ncomp;

Undefined variable $rsnew in C:\xampp\htdocs\hola\models\Remates.php on line 247

luchidemus wrote:

$this->ncomp->addMethod(“getAutoUpdateValue”, fn() => BuscoNuevoRemate($rsnew));

You cannot use $rsnew in AutoUpdate value, there is no $rsnew in the context. The $rsnew is only available in server events such as Row_Inserting/Inserted/Updating/Updated.In fact your function BuscoNuevoRemate() does not use $rsnew at all, you should change BuscoNuevoRemate($rsnew) to BuscoNuevoRemate().