Forum Discussion
Audi86
Aug 25, 2022Copper Contributor
Converting code to run on single item by disabling for loop
hi, Below i have a chunk of code which is running on each item in my SharePoint online classic document library using a for loop. I want to modify it as a test to run on a single ite...
- Aug 26, 2022After line 36 with a if ($ListItem | where id -eq 10) {
Aug 26, 2022
You could use a breakpoint in VSCode?
- Audi86Aug 26, 2022Copper Contributoris there anything i can use in powershell code itself. its a try and catch code with for loop but if i want to test this code on only one single item then what modification i can do? any idea?
- Aug 26, 2022If it's not a specific item, then you could use 'break' to stop the script at any point, after line 23 I guess. That way you have all the data in the variables and only process the first item in the foreach loop. If it's a specific item, then you could insert a line before 10 with an 'if ($WorkflowInstance -eq 'xxxx) {' and then a break after line 23 so that it stops processing other items
- Audi86Aug 26, 2022Copper Contributorsorry for not very clear on my query but its for first loop. i am looking for specific ListItem. I have pasted full code in question now just incase