0
votes

My form contains a numeric field called: txt_number, it is computed and it is the sum of two editable numeric fields: txt_no1 and txt_no2.

All the txt_number fields are stored in a view ( to be able to get the element before) , in this way:

@Unique ( @DbLookup( "" : "NoCache" ; @DbName ; "vwTest" ; field1+field2 ; 2 ));

"vwTest" has 2 columns: the first is categorized ( field1+field2 ) and the second one has txt_number as its default column value.

So, the list from my topic question is "vwTest" containing all the txt_number values in the 2nd column.

Let say the first doc saved will have txt_number = 5. When a new doc. is created, and txt_no1 and txt_no2 are calculated , we get txt_number = 10 .

The form has a computed field called txt_diff where I want to obtain the difference between the last txt_number and the actual one.( 10 - 5 = 5 )

So, if then it will be another new form with txt_number = 50 => txt_diff ( on this new created doc ) should be 50-10 = 40.

vwTest: field1+field2 | txt_number

  • List item

                  |   1   ( => on this doc, `txt_diff = 1` )
                  |   10  ( => on this doc, `txt_diff = 9` )
                  |   23  ( => on this doc, `txt_diff = 13`)
       .......................
    

Please , I need your help. Thanks!

1
What is your question? - Ken Pespisa
I think this is very confusing. You are saying two different things: "txt_number... is computed and it is the sum of two editable numeric fields" and "The txt_number field si taken from a view, in this way:". It obviously can't be both! More confusion: what are field1 and field2? You use them in your @DbLookup, but you don't mention them anywhere else in your question. (And BTW: for most Notes developers, the prefix "txt_" is used for text fields, not number fields. This also makes your question confusing.) - Richard Schwartz
I edited my question, hope to be clear. Both field1 and field2 are two editable fields on the form. - Phaul Guen

1 Answers

0
votes

It still some confusing but, if I understand you, you need to calculate txt_diff using that view as reference.

In that case, you can put some code in event QueryRecalc or QuerySave to do the calculation. This is an example code:

(I'm coding by memory, so it can have some errors)

dim o_view as NotesView
dim o_nav as NotesViewNavigator
dim o_doc as NotesViewEntry

set o_view = o_current_db.GetView("view_categorized_by_field1_field2")
set o_nav = o_view.CreateViewNavFromCategory(field1+field2)
set o_doc = o_nav.GetlastDocument  '<== THIS IS YOUR DOCUMENT TO CALCULATE txt_diff

'Do something more 

However, unless you need txt_diff in real time, you can create an agent to do the calculations every X minutes. Both solutions depends of what are you need in your app.

I hope this helps.