The code on your screenshot is correct, that's exactly how it should be done. I don't know why are you getting "Save as" dialog, must be some other event.
IT IS?? ok... I wasn't sure at all, that's a progress for me.
So, just for testing if I disable the:
Start of Layout > Functions | Call Undoinitialize
The "Save As" issue won't appear... so I'm trying to look what I did wrong, and how to fix it.
I don't know how to "start over" maybe I'll rename the "Save As" for fresh test because I don't know how to get rid of this issue so I can proceed.
I disabled the SAVE LOAD - SYSTEM group, and the UNDO system doesn't work at all on my project.
I have no idea what I did wrong even with all the organized groups it is a mess to find the issue, I can only guess it's a mess related to the JSON or whatever data these two systems work with...
Or maybe because I use Families? (which I must)