Saving WQO-Set Fields With the Document
Have you ever set a field's value on a Form using WQO code only to find the field doesn't save with the document once the user submits it?
Confusing, innit? It's like the whole Form gets recomputed once you submit it. Assuming you want to store the values in the document, all the computed fields whose values you set in the WQO need resetting in the WQS, which means duplicating the same bit of code.
Well, there's an easier way. All you need to do is get the browser to actually submit them as part of data from the HTML form. To do this you can simply add a computed text area to the form with the following code:
Fields:="Name":"Street":"County":"Phone"; @Implode( "<input type=\"hidden\" name=\"" + Fields + "\" value=\"" + @GetField(Fields) + "\">" )
In this code the Fields variable lists the names of all the fields whose values were computed by the WQO. As an example I've used the concept that the WQO has found the user's profile and is showing them a non-editable set of their stored details as part of a form submission. For whatever reason the document created needs to store these details, so the form now includes the following HTML:
<input type="hidden" name="Name" value="Bobby"> <input type="hidden" name="Street" value="Letsbe Ave"> <input type="hidden" name="County" value="POL"> <input type="hidden" name="Phone" value="999">
Obviously this leaves the data open to hacking by the end user, which isn't perfect, but I've found it adequately safe for the couple of occasions I've needed to use it. As ever, horses for courses.
That design feature is fun. I'd always abstracted out general fields and had a WQS save the values on the back end.
That being said, you could do a lookup on the computed text and then evaluate out the field, meaning you could have a custom/userdefinable field with user-def fields completely web driven, too. Fun stuff.
This approach works only for R6+ servers. Used to be a nightmare to manage such a hack in R5 servers. R4, R5 server would not except anything but a notes field.
But then, how many of us still are proud to run R4/R5 servers ?
We have come a long way in the world of Domino web programming :)
Thanks for reminding us all what Domino used to be.
I am not sure if you need those fields in views etc but often I have the situation where I have fields that are only used in the interface and are never needed for views. In these cases I have started creating a single field on the form and writing JSON to it. On open I eval it and then update it as needed during page use. On save I serialize it (see JSON.org for the library) back to the storage field and continue with the save. It saves the clutter of fields on the top of the form that you never really care about except for the interface.