Need help... saving after edit document

The subject of this posting could be a bit confusing. A user opens the document in read mode (so far so good) then desires to edit. The “edit” button is clicked. I am using (though I have used javacsript as well) the @URL open with ?editdocument and &lockstatus=locked in the URL. This works… places document in edit mode and sets the lockstatus field. So far so good… the problem is that the document needs to be saved (while still open for edit) right after the lockstatus field is set. How can I save the doc in this case? Do I need to run a macro/agent behind the URL? I have tried WQO (seems to save before field is set), onload is causing loop, etc. Any ideas? This seems so simple… guess these late nights are clousing my thoughts!

Subject: Need help… saving after edit document

Method 1: On the Onload Event

Only run the agent when the lockstatus=locked flag is set …

this will remove the loop problem…

Method 2: WQO Event

Stamp the field value (as you said) and then once the document is loaded lookup this field value by using the computed for display field and using the formula: @GetDocField( @DocumentUniqueID ; fieldName ).

Hope this solves the problem

Subject: RE: Need help… saving after edit document

Many thanks… see comments below:

Option #1 (onLoad):

Could I use a formula? e.g. @If(LockStatus=“Locked”; @Command([RunAgent]; “savelock”); “”)

***savelock would just be a simple agent with @Command([FileSave]). That said… couldn’t you just include this in the formula (like below)?

@If(LockStatus=“Locked”; @Command([FileSave]); “”)

Option #2… I should only need the above, right? …if using an edit button to set the field value.

Subject: RE: Need help… saving after edit document

I need some clarification… can I use formulas in the onload? I know you can for Notes clients… am wondering about web. I am still missing something. I even tried document.forms[0].savelock.click() in the onload… savelock is a button with display:none in HTML properties. The formula in the click is below:

@If(@IsDocBeingEdited; @SetField(“tmpLockStatus”; “Locked”); “”);

@Command([FileSave])

What am I doing wrong? This is painful… because I know it must be simple. Could I place a …URL/updatelock?openagent behind the “edit” button and have it set the field + save? This would bypass onload. A formula like this…

@Command([EditDocument]); @SetField(“tmpLockStatus”; “Locked”); @Command([FileSave])

I’m getting the old @Function is not valid in this context

message when the form attempts to load in read mode (from view)… I’m assuming there’s an issue with it running the above commands. Maybe these should be in an agent… just call agent from button.

Update: this did not work… started with invalid URL (was including DocDI in path) then just popped up an agent done message. I know that a $$Return field could address this part. It still did not update/save. Hmmm…

Could I place a formula in the HTML Head Content? This is a definite NO…

What about a computed field -w- formula that has save? This is driving me nuts… I do it all the time when a doc is in edit mode. e.g. user clicks status button and it chnages field & saves, etc… I’m just looking for a way to save after the form opens in edit mode. The fields would have already been set… ideas, options…?