Import validate or roll back

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
crash
User
Posts: 148

Import validate or roll back

Post 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.


MichaelG
User
Posts: 1095

Post by MichaelG »

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


crash
User
Posts: 148

Post 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;
}

MichaelG
User
Posts: 1095

Post by MichaelG »

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


crash
User
Posts: 148

Post by crash »

Thanks, got it fixed


Post Reply