This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - How to add validation in BatchLoader?

leena_suryawanshi - Monday, July 18, 2011 6:55 AM:

I want to bulk upload the data from .csv file to SQL Server through BatchLoader.exe utility.
While loading the data I want to put a condition on a column of .csv file.
Like If the column1 has value 'No' the BatchLoader should skip that row and should stop the loading process there.

 

Is there a way by which we can input such conditions within BatchLoader? If yes, please provide me an example of the same.



Brian - Wednesday, July 20, 2011 6:51 AM:

Hi Leena,

I'm fairly sure there is no way to put that filtering on the batch loader.

But you could open the CSV file in Excel and pre-filter the bad records out. This is a preferred method of scrubbing data.

You could also write a server method for the Item type that is being loaded and trigger it on "onBeforeAdd" and try to validate the data there. The method should return an error if your condition is not met. This should do what you want I think.

Cheers,

Brian.



leena_suryawanshi - Wednesday, July 20, 2011 7:46 AM:

Hello Brain,

The approach of writing our condition in a method on event "onBeforeAdd" looks good. It will help me solve all the conditions I want except the following:

I would like to read the values being added for an item.

E.g. if I am adding an item "Part" with Item_number value as "P001"., in the validation method I want to read the value "P001" before the item is added. How can we achieve this?
I appreciate if you have any pointers on this query.

Thanks and Regards,
Leena



Brian - Wednesday, July 20, 2011 8:58 AM:

Hi Leena,

In the onBeforeAdd method the context item is the Item being added.

For your Part Item you can find the Item_number with a standard "this.getProperty("item_number")" call.

I think I might be missing the point of your question.

What do you want to do with the Item number before the Part is added to the system?

Do you want a user to actually See the Item number and be able to make a decision about it or change it in some way?

I'm sorry if I haven't been able to help.

Cheers,

Brian.



leena_suryawanshi - Friday, July 22, 2011 1:25 AM:

Hi Brain,

Thanks for the reply. I will explain you the whole scenario.

I have one .csv file in that file I have Item_number,Column1 as columns.

Now If any row of Column1 has a "No" value. then the system(BatchLoader or ARAS Innovator) should not allow me to enter that row.

So how to achieve this. I tried the Method way, it is working for Innovator but not in BatchLoader.

Thanks & Regards,

Leena.



Brian - Friday, July 22, 2011 8:48 AM:

Hi Leena,

I'm fairly sure that you can't use the batch loader directly to validate the information being loaded.

You could set the "Column1" property in Innovator to Required. Then if the value wasn't supplied the batch loader would fail on that record. I'm not sure if that would do what you want.

Setting an onBeforeAdd method is probably the best method of validating the information and just throwing the invalid data away (or writing it to another Item type as an error).

Cheers,

Brian.