Check the record imported from the excel is exist or not?

Hello 

i do not know how to carry on this. 

i like to check the new records imported from the excel is already in the entity or not.

if yes , show the error message and if no, add the new records of excel to the entity.

loss the way in the IF place. if someone knows how to deal with that please guide me .

for more info, oml is attached. 

thank you so much in ahead.


Hi Ann,

Your If is comparing to the Current of GetMasters, but that's only a single record (the first one).You should use a ListAny to check whether the current ConvertFromExcel record exists in the GetMasters List. See attached OML.

 wrote:

Hi Ann,

Your If is comparing to the Current of GetMasters, but that's only a single record (the first one).You should use a ListAny to check whether the current ConvertFromExcel record exists in the GetMasters List. See attached OML.

Dear Kilian 

Thank you for the ListAny explanation.

i have a further question, when i debug the app, after upload, the new record  from excel is only comparing to check the entity current record, and Returns always false. 

I tried to get the Returns True, by uploading the changing record in excel.

it didnt work out yet sir.


Thank you again




ListAny searches the entire input List for a record that matches the condition you specify. If it finds one, it returns true. You should check the condition in the ListAny to see if what's in there matches what you expect (in my example, I copied the conditions from the If in your OML).

Solution

Weird, I got a reply notification, but the post isn't here... So copy/pasting from the e-mail:

Ann Joss wrote:

This is so strange however i check/correct the condition of ListAny, it does not return to the True . The records of the excel checks only to the entity first row, I tried like this. SyntaxEditor Code Snippet ConvertFromExcel.Current.Master = Master new records from the excel is equal to the original master. Is there any other method to set in the condition?

It's a normal condition, with the exception that you don't use the List variable's name, since you already specify that in the Input Parameters. So it's just a matter of tuning your conditions. Note that string compare is pretty strict, so if there's a trailing space in the Excel, for example, the compare will fail. Also, capitalization differences matter.


Solution

Kilian Hekhuis wrote:

Weird, I got a reply notification, but the post isn't here... So copy/pasting from the e-mail:

Ann Joss wrote:

This is so strange however i check/correct the condition of ListAny, it does not return to the True . The records of the excel checks only to the entity first row, I tried like this. SyntaxEditor Code Snippet ConvertFromExcel.Current.Master = Master new records from the excel is equal to the original master. Is there any other method to set in the condition?

It's a normal condition, with the exception that you don't use the List variable's name, since you already specify that in the Input Parameters. So it's just a matter of tuning your conditions. Note that string compare is pretty strict, so if there's a trailing space in the Excel, for example, the compare will fail. Also, capitalization differences matter.


Thanks you so much sir .

Finally i got it. 

Thanks for the guidance..



You're most welcome. Happy coding!