I do this type of thing all of the time and have not had any issues. Are you sure you are saving the file before you leave designer?
Yes, I'm sure I saved it. Even if I didn't save it, Workbench would ask me to save when I close Workbench.
I was able to reproduce the problem many times yesterday.
Create a simple XDP in Workbench, and put a button on it. Write a script to show message box when clicked. It works fine. So I close Workbench, restart it, open up the XDP and the script is gone. But the message box still shows up when the button is clicked.
I followed your instructions and it worked fine for me. Which version are you using.
It's 126.96.36.19958.1.475346 and the server is installed on 64-bit machine.
I have the same build but on a 32bit machine ...sounds like you may have found a bug ...I would open an incident with support.
I hope it's not a bug but a simple config issue or something like that.
I've found an interesting behavior.
Yes, it works fine if I just create a simple button and write scripts in the click event.
But it happens when I write scripts in the button that invokes a web service.
I created a simple web service called HelloWorld with no input and return value "Hello World".
I create a data connection to an existing WSDL file and drag and drop HelloWorld response and HelloWorldBtn.
And write a script in the HelloWorldBtn button's click event then it disappears when the file is closed and reopened.
Hope this could help you help me.
I think I've found the issue and it seems to be a bug.
Like I said earlier, it only happens to the button whose control type is set to "execute" which is the default type when created by drag & droping from data view.
This is how I reproduce the issue.
After creating the button, write a script to show a message in the click event and it works fine until it is closed.
When reopened, the script is gone but the message still shows up.
Write another script to show a message and now it shows two messages.
Close and reopen it, then the script is gone again but still shows two messages.
Now change the control type to "regular" then only the last script (not two) shows up in the script window.
Remove it then now it shows only one message.
Close and reopen, then it shows the first script.
When I create regular button and try to change the control type to "execute", it warns that the click event will be removed. But not shown in the other way. In addition, i'm not allowed to write scripts if the control type is "execute".
Anyway, I'd like to point out two things;
First off, if "execute" tpye of button is not supposed to have scripts it should not allow writing scripts in the script window in the first place just like when the type is changed to "execute" from "regular".
Secondly, it should show all the scripts at once when the control type is changed from "execute" to "regular", not one at a time when it's reopened. Because it's not version control, it's just a property change.
You are right ...you are not supposed to have code on an execute button. My guess is that when you add the code in the 1st place it is getting inserted into the template (look in the XML source I'll bet it is there). When you reopen the form later then the code shows up because iti sbeing read from the template. I agree that it looks like a bug. I suggest you open an incidient with support to get this fixed.