Page 1 of 1

Import validate or roll back

Posted: Mon Feb 27, 2023 5:20 am
by crash

I have a 13-digit validation set as a regular expression. This means users can onli input numeric values and and must be excatly 13 digits.
"^[0-9]{13,13}$"
When I import I want to validate the import first.

The system does not block it or allow rollback.

Can anyone hlep.


Re: Import validate or roll back

Posted: Mon Feb 27, 2023 6:30 am
by MichaelG

Use the Row_Import server event to validate the data. Read:
https://aspnetmaker.dev/docs/#/customsc ... row_import


Re: Import validate or roll back

Posted: Tue Feb 28, 2023 6:56 am
by crash

I am using page import, and even though it says failed, it is still adding to the table.. and it's not prevent anything

Here's my code

// Row Import event
public bool Row_Import(Dictionary<string, object> row, int cnt) {
    //Log(cnt); // Import record count
    //Log(row); // Import row
    //return false; // Return false to skip import

if (Convert.ToString(row["My13digitNumber"]) == "^[0-9]{13,13}$") // Quantity must be <= 100
		return true; // Skip import
	
    return false;
}

Re: Import validate or roll back

Posted: Tue Feb 28, 2023 11:07 am
by MichaelG

Your checking is wrong. Use Regex.IsMatch to check the value against regular expression.


Re: Import validate or roll back

Posted: Thu Mar 02, 2023 4:59 am
by crash

Thanks, got it fixed