0

Notes 9.01

Why does a new document on the web change unique IDs every time you refresh it?!? this causes all kinds of issues. Obviously it is a different document, so maybe I should re-phrase that, but I think you know what I am saying.

I have a listbox field, with the setting to "refresh fields on keyword change" selected. This allows hide-whens to recalc, and other fields to recalc. I also have a computed text showing the current @DocumentUniqueID.

choices are: "Select one":"one":"two":"three"

When using this form on the web, in a new document, and I pick something in this field from the drop-down, it refreshes the form, and the choice I just picked is removed and "Select one" is what is showing again.

Once the document is saved, this stabilizes and you do not switch documents, and field values do not get cleared. I just want to understand the logic of this and find out how other people work around this.

Any feedback would be great. If I am doing something stupid, please tell me, I can take it.

  • Matt
Matt Smith
  • 121
  • 7

2 Answers2

0

I don't know what the "all kinds of issues" that you're dealing with are, but for as far back as I can remember, Notes documents have not had a stable @DocumentUniqueID value (or any at all, actually) prior to being saved for the first time. It's been my practice, and I think pretty widely accepted practice, not to write code that would have issues with that. If it's been necessary to depend on some unique value in the document prior to the first save, I've always used a computed-when-composed field with @Unique for its value.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • The example I stated in the question is what I am dealing with right now. I have a field with multiple choices, and when I pick an option, it refreshes the form, and what i just selected is removed. This seems to happen BECAUSE the document I picked it on is replaced with another with it's own unique ID. I only mentioned the ID because it was evidence of what is going on. However, the ID is showing in my computed text as soon as the document first opens as a new one. – Matt Smith Mar 14 '19 at 14:44
  • Well, the direct answer to your question is that the refresh operation requires a server round-trip in order to evaluate formulas, and since the Domino nhttp task is stateless (as web servers are supposed to be), nothing was held in memory after your initial display of the form and nothing was saved on disk. That means that in order to run your transaction, a POST operation occurred, but it's a post to an unsaved note. The Notes API does not have any option for recreating a note with the same UNID as the previous one. (That would be bad!) Therefore @DocumentUniqueID changes. – Richard Schwartz Mar 17 '19 at 14:31
  • The issue with losing your selected keyword is, apparently, a bug. The POST should have sent that value up the the server, and nhttp should have applied it to the new (temp) document that it used to generate the redisplay of your form. Instead, it sounds like it is applying the default value formula. (The only other thing I can think of is that you might have a misbehaving an input validation formula for the field, but I'm guessing you've already ruled that out.) – Richard Schwartz Mar 17 '19 at 14:35
0

My suggestion would be to not use "refresh fields on keyword change" for a form used on the web. The way I would handle it is to use some JavaScript to handle that.

Personally I would do this, in your situation:

  1. Add jQuery to the form, you can easily put a CDN link in the page header.
  2. Write a JavaScript function called (for example)brecalculateFields(). This function would calculate field valuesband perform hide/show of fields/sections of the form.
  3. Set a class for all fields where you want to trigger a recalc of the fields when the value is changed. I would call the class recalcForm.
  4. Bind the function recalculateFields() to the changed event of all fields with the class recalcForm.

You may want to bind the function to a few other events as well, depending on what type of fields you have on the form.

$(".recalcForm").on("change", function(e) {
    recalculateFields();
});
$(".recalcForm").on("blur", function(e) {
    recalculateFields();
});

I have blogged about this in the past, hopefully you can use some of the info there:
http://blog.texasswede.com/using-jquery-to-emulate-notes-hide-when/
http://blog.texasswede.com/jquery-a-flexible-way-to-showhide-sections/

Karl-Henry Martinsson
  • 2,770
  • 15
  • 25