Deleting element at the end of a script

I have written a script. It creates levels and associated view names then duplicate the view names to create additional views. I then want to clean up at the end by deleting the original views. I’m using the Delete Element node to delete the unwanted views. My problem is it deletes the original views at the same time it is creating the other views so off course it errors. If I was doing traditional programming I could step through my function line by line and clean up at the end or pass my data out to another function that cleans up. I have tried to use transaction end to finish my main script and then transaction start to do the clean up. But it doesn’t work. I have looked at the function node but to be honest I can’t make head nor tail of how it works. The documentation on it is very poor. Any ideas how I can do the above. To summerise I would like to run one piece of code after another

Hey Dan,

You should take a look at the Transaction nodes. Here’s a link:

These should be able to get you the result you need.

Also you can use the Function.Compose node, it’s mentioned in the same thread as linked above.

Here’s another discussion that should prove helpful: