Profile Documents in the browser. Can't be done right? Well, I think I might have found a simple way round it using the combination of a simple WQO and WQS agent.
I have a Notes client database that needs converting to the web. One of the tasks is to find a way to still allow users to edit their profile documents. At first I thought it wasn't possible, then I had a thought. Why can't I open the actual Profile Form and then use a WQO agent to copy all the fields over. When the user submits the form it simply copies all the fields back to the profile and saves it.
Let's say we have a profile based on a Form called "UserSettings". It's opened in the Notes Client in the usual way. Now, in the browser I suggest using a URL like:
This form has a WQO agent ("Run as Web User" enabled). The important code for which is:
Set vProfileDoc = vThisDB.GetProfileDocument("UserSettings", vWebSess.EffectiveUserName) Call vProfileDoc.CopyAllItems(vThisDoc, True)
Simple, no? Just copy all the item values over! Because it's the same form, in effect, all the fields are laid out as expected and it looks like the normal profile document.
To save the profile we need to add a WQS agent ("Run as Web User" enabled). The basic code for this is similar to the above (we still need to get a handle on the Profile) but looks like this:
Call vThisDoc.CopyAllItems(vProfileDoc, True) Call vProfileDoc.Save(True, True)
Notice the CopyAllItems method has its document parameters switched. Notice also that we save the Profile document. This is important and something I forgot when I first tested the theory. Doh!
Another thing we need to do is add a SaveOptions field the Profile form. Because we're opening it like a normal form in the browser we don't want it to save. So, make the field hidden and computed then add a formula like this:
@If(@ClientType="Web"; "0"; "1")
I've done some crude testing and it all appears to work. Have I missed some detail that means it won't in reality? What normally happens is I find something like this and think "Must blog that right away!". What I should probably do is sit on it for a while and see how stable it is. This saves me looking like a fool if it isn't. Oh well, what the hell.
What struck me is that it's such a simple solution. I'm surprised I've not seen it described elsewhere. Has this been done before? If not, should I write a more detailed explanation/article and knock together a demo db for download?