I presume that that code executes on button click.
So you can add simple action: Basic-confirm action. Enter the text you want.
After that, you can add another simple action: Basic-execute script in which you put your code that saves document.
Hope it helps!