79157984

Date: 2024-11-05 07:15:11
Score: 0.5
Natty:
Report link

Problem is that within a foreach when you're at item() level, you're comparing the value with body/value which is an object. It will certainly 'not contain' the ID you're passing and will always generate a new record.

here an approaches to do this.

Get all IDs in the excel with a select and then check for the ones that dont exist. then add them.

enter image description here

As you see, the condition is now false. Ensure that the datatype of your ID is string (parse it using string() function if not) since select always returns an array of strings.

enter image description here

Better approach

an even better approach to avoid repetitive conditions in the foreach loop is by using a filter array to get all items that don't exist and then create them in the loop.

here's a sample structure using filter array

enter image description here

only six out of 20 were added

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Laviza Falak Naz