How to validate decimal input for integer attribute during excel import?

0
Hi everyone, šŸ˜ƒ I’m working on an app where I import data from an Excel file. One of the attributes in the imported file is Amount, which is supposed to be an integer (e.g., 1, 5, 10). However, some users are entering decimal values (e.g., 1.2, 5.5), and I need to ensure that only whole numbers (integers) are allowed. Issue: When I import the Excel file into Mendix, if a user enters a value like 1.2 in the Amount column, Mendix automatically rounds it to 1 during the import. While this rounding is fine, I would prefer to catch these decimal values during import and give a validation error to the user. Question: How can I validate the Amount column so that it only accepts whole numbers (integers) during the Excel import process, and reject or flag any rows where a decimal value is entered? Should change the data type.. or what Any suggestions on how to handle this validation check would be greatly appreciated! Thanks in advance for your help!
asked
1 answers
2

Hi Selcuk,

Go to import excel microflow store $rowCount value in the integer variable $storeRowCountValue.

Retrieve your currently imported data in the xpath select custom and in the 

amount section just pass this variable $rowCountStoreValue and sort on the basis of currDateTime in decending order 

 

Now you have exactly currently imported data 

take a loop pass this list and iterate them

in the decision box check isMatch($Iterator/Amount, '^[0-9]+$') if this true do continue but if this false change the $IsDecimal(true)  

create another boolean variable before this loop $Isdecimal(false) and change the variable value in the false condition $IsDecimal(true) and break this loop using break event.

 

Lastly Outside of this loop just take a decision in the decision check $IsDecimal=true means list have some decimal value just show a validation feedback please enter integer value and delete the retrieve list but if $ISDecimal=false means there have no decimal value just end the event with one show message successfully impo.

 

You can also give the row number where the actually user entered the decimal value with the help of another entity.

 

Hope you like the answer.

 

answered