in my codeless im loading data from a table then looping the results
now how can i delete the current object in the loop?
i tried this and it didn’t work
yes i have that and its on the pic i posted
but it need a number
Use the “print” block to debug. You will get the output of “print” in the log file.
what do you want me to print? cant print the remove action.
The “print” block will help you to debug your logic. Using print you can log information in the log file. Do you know how to do it?
yea i know.
my logic is working except the action to delete the object form the list.
why cant i delete the object by referencing the object in the loop? do i have to pass a number to the delete action in the list?
You are passing the number “count”, but I do not know what that number is and if it is a valid value. Plus you are modifying the array which you are iterating over. Not sure if this is allowed either. That’s why I suggested to debug to get these questions answered.
and thats why i asked how to get the number.
im setting the number to zero before the loop and increasing it by 1 in each iteration.
do you suggest a different why to delete some objects from the list?
There is only one block to delete an item from the list and you using it.
- Are you sure the value of the “count” variable is correct? If yes, how did you verify it?
- Are you sure you can remove an item from an array while iterating over it? If yes, how did you verify it?
1- i see the output of the “count” and its correct for the list objects count.
2- i am able to remove all the objects correctly. except the last object in the list.
the delete block tool-tip say that the list start at 1
so i try to set “count” to 1 instead of 0
and it still let one last object in the list
Try to put the entire logic into a try/catch block and see if there is an error.
no errors
i think you cant delete the object when you are in loop.
because after the delete action and block does not execute correctly
so how can i delete the objects then if i cant delete them from a loop?
Create a list which will contain IDs of the elements you need to delete. When you finish iterating over “requests”, start a loop of the second list to delete items from “requests”.
But i need to supply the delete block with element position not IDs. right?
Yes, to delete you need to provide the index.
but how is your solution is going to help?
im still not be able to delete the items by the IDs
will these do the required action? there is no documentation for them.
- Create a separate list, call it
indexesOfObjectsToDelete
- When you find an index of request to delete, add it to
indexesOfObjectsToDelete
. So you will end up having something like this:
indexesOfObjectsToDelete[ 0 ] = 2
indexesOfObjectsToDelete[ 1 ] = 5
indexesOfObjectsToDelete[ 2 ] = 9
- When you’re done with the first loop (the one you showed in the screenshot at the top of this topic), start a second loop for the
indexesOfObjectsToDelete
list. - For each iteration of that second loop, delete an object from the
requests
list at the value for the current element fromindexesOfObjectsToDelete
.
Makes sense?
yes i get it now
seems a lot of overhead work, hope you guys implement a better and shorter solution.
Thanks Mark!