Ok, so I have taken my base form - no qrules and no Username() and added some code which sets a field to "newvalue" - boy was I rusty at that ! It is 2.5 years since i have written any code.
I published the form and it works fine.
I then included the username() function in one of the fields and re-published. Again it publishes successfully but when you try and run it it gives a correlation error.
So in our set up it seems that if you use the username() function in conjunction with code (qrules or other) it fails.
The code on its own is fine.
The username() on its own is fine.