Add 2 letters to value

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
grzegorzrolewicz
User
Posts: 6

Add 2 letters to value

Post by grzegorzrolewicz »

Hello,

I have a variable called "Production" which should be in format "ZPxxxxxx" where x is a digit.
In old PHpmaker version there was a server event that was adding those "ZP" letter so person was typing just digits.

In 2024 i got this error when i try to add a record:
Undefined constant "PHPMaker2024\DT2024\Production"

The server event looks like this:

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
	// Enter your code here
	// To cancel, set return value to FALSE
	$rsnew[Production]='ZP'.substr('000'.$rsnew[Production],-6);

	return TRUE;
}

Any idea how to fix it? or any other solution how to make this "ZP" automatic (like a mask?)


mobhar
User
Posts: 11905

Post by mobhar »

Your code should be:

$rsnew["Production"]= "ZP" . substr("000" . $rsnew["Production"], -6);

grzegorzrolewicz
User
Posts: 6

Post by grzegorzrolewicz »

Thank you it works now!!!


Post Reply