Auto Update of a Field

All,I have a Text/Computed field that I want to set to Yes when the RemainingApprovers field in empty. (This is done elsewhere and is working properly)

I have the following code in this field now, and it kinda works:

@If(@IsNewDoc; “No”; @If(RemainingApprovers = “”; “Yes”; “No”))

However, my issue is this, on a new document creation, when you submit the document for approval, I have a JS button to do the submit,

var doc = document.forms[0];

doc.AgentRunner.value = “”;

validateFields();

doc.submit();

then it fires of the WebQuesrySave agent which updates a few fields, returns the display to a different form, which therein it is no longer a new document, and is setting the field to YES automatically. It should remain No when it is submitted.

At this point in the process (new document creation), there is no subform on the document that contains the RemainingApprovers field. It becomes available once it is submitted (i.e. after this process). I do not think this is the issue, but wanted to include this as well.

In fact I would prefer if the code did not even look for the RemainingApprovers field until after it is submitted if possible.

I would appreciate a review of that formula to see if there is a better way to write this.

Thanks

David

Subject: Auto Update of a Field

What happens is that the field recomputes when you reopen it so it is not a new document and RemainingApprovers is still blank so it sets the field to Yes.

There are several different solutions but one is to set the field to computed with the value of the field name and then set it in your webquerysave agent by testing the IsNewNote property of the notesdocument class.

However you set the RemainingApprovers field(e.g. by agent) should also recompute this field.

Subject: Auto Update of a Field

I would have an additional flag field that will let me know if the document was submitted or not. You can set this field thru javascript when the form is submitted then the code in the button would look somewhat like this:

@If(RemainingApprovers = “”; @If(DocSubmitted=“Y”;“Yes”;“No”); “No”);

You wouldn’t really need to check if its a new doc in this case and anyway you can’t use really use it to know if the document has been finally submitted or not.