Lotus Notes 7 - Auto-calculation for one column from an editable view - InViewEdit event -


i have problem gives me headaches lately. hope can find solution help.

i have view : "vwtest" embedded on form. editable view. view has 3 columns: number , cost , difference. 3 columns have default values field names exist on form called "fmtest", field names are: number , cost , difference.

on main form ( contains view ) there field ( computed ) called: totalvalue.

the view has 2 actions: addline , deleteline.

what want is:

let totalvalue = 5000

  • user complete first line of view:

number | cost | difference


1 | 50 | 4950 => 3rd column value calculated automatically difference between 5000 ( totalvalue ) , 50 ( value of 2nd column )

  • user complete second line of view:

2 | 60 | 4890 => 3rd column value calculated automatically difference between last 3rd column value view , 60 ( current value of 2nd column )

i think that's recursive algorithm.

the value of totalvalue exists, number type field.

hope find solution , resolve problem! appreciate , time!

after every save have cylce through entries belonging "this" main document , recalculate totals. assume, "lines" response- documents main document , embedded view categorized unid of main document...

dim ses new notessession dim db notesdatabase dim viewembedded notesview dim viwnav notesviewnavigator dim ve notesviewentry dim docline notesdocument dim docmain notesdocument  dim dbltotal double  set db = ses.currentdatabase set docmain = ... 'somehow main document, therefor need current code dbltotal = docmain.totalvalue(0) set viewembedded = db.getview( "vwtest" ) viewembedded.autoupdate = false set viwnav = viwembedded.createviewnavfromcategory( docmain.universalid ) set ve = viwnav.getfirst() while not ve nothing   set docline = ve.document   dbltotal = dbltotal - docline.cost(0)   if dbltotal <> docline.difference(0)     docline.difference = dbltotal     call docline.save( true, true )   end if   set ve = viwnav.getnextdocument(ve) wend 

why loop? if modifies first line after second 1 , third 1 have been created? total 2, 3 , subsequent lines has change.

this code not typed in designer , might contain typos. not contain error- handling , can produce replication / save- conflicts if not used carefully..

hope helps


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -