Manage Learn to apply best practices and optimize your operations.

Simulating The Functionality Entering Data In A Table Or A Grid

Normally, some of the functionality like entering the data in a grid is tedious
in lotus notes. But here is the simple code to achieve that functionality
Let us take the example of sales invoice

Create a form and a sub form

Have fields itemname, quantity rate. All these three fields should be placed in
a table for alignment and the properties should be set as text,computed.

Create hidden fields curitem, curquantity,currate,flag and RowValue

Create buttons Add,Edit and Delete

The code goes as follows?

Add_click formula

@SetField("curitemname";"");
@SetField("curquantity";"");
@SetField("currate";"");
@SetField("flag";"0"); ?O-adding a record, 1-editing a record, 2-deleting a
record
@DialogBox("multisub" ; [AutoHorzFit] : [AutoVertFit] ) ?Multisub is the name
of the subform

Edit_click formula

rownumber:="";
OriginalList:=itemname;
@If(itemname="";@Prompt([OK];"Information";"There is no data to edit");@Do(
@Set("rownumber";(@Prompt( [OKCANCELEDIT]; "Modification" ; "Enter the row
number to be modified" ;"" ; "")));
@SetField("curitemname";@Subset(@Subset(itemname;@TextToNumber(rownumber));-1));
@SetField("curquantity?;@Subset(@Subset(quantity;@TextToNumber(rownumber));-1));
@SetField("currate";@Subset(@Subset(rate;@TextToNumber(rownumber));-1));
@SetField("flag";"1");?1-editing the record
@SetField("RowValue";rownumber);?Value field gives the number of the row to be
edited
@DialogBox("multisub" ; [AutoHorzFit] : [AutoVertFit] )))

Delete_click script
?The concept of deleting is making the data to be deleted as blank and trimming
so that the row is removed from the list
Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument
Set uidoc=ws.currentdocument
Set doc=uidoc.document
If doc.itemname(0)="" Then
Msgbox "There is no data to delete"
Exit Sub
End If
Dim varitemname As Variant
Dim varquantity As Variant
Dim varrate As Variant

varitemname=doc.itemname
variquantity=doc.quantity
varrate=doc.rate
Dim deleterow As Integer
deleterow=Inputbox("Enter the row number to be deleted")
varitemanme(deleterow-1)=""
varquantity(deleterow-1)=""
varrate(deleterow-1)=""
Call doc.replaceitemvalue("itemname",varitemname)
Call doc.replaceitemvalue("quantity",varquantity)
Call doc.replaceitemvalue("rate",varrate)
Varitemname=Evaluate ("@Trim(itemname)",doc)
Variquantity=Evaluate ("@Trim(quantity)",doc)
Varrate=Evaluate ("@Trim(rate)",doc)
Call doc.replaceitemvalue("itemname",varitemname)
Call doc.replaceitemvalue("quantity",varquantity)
Call doc.replaceitemvalue("rate",varrate)
End Sub

The sub form also has to be created with the same fields as like form
But the fields itemname,quantity and rate should be hidden and
curitemname,curquantity and currate has to be made visible

The below mentioned code has to be attached to the sub form

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
Dim doc As notesdocument
Dim itmitemname As notesitem
Dim itmquantity As notesitem
Dim itmrate As notesitem

Dim varitemname As Variant
Dim varquantity As Variant
Dim varrate As Variant

Set doc=Source.document

Select Case Trim(Source.fieldgettext("flag"))
Case "0"
'Add function
Set itmitemname=doc.getfirstitem("itemname")
If itmitemname.contains(doc.curitemname(0)) Then
Msgbox "Itemname already added"
continue=False
Else
Call
itmitemname.appendtotextlist(Source.fieldgettext("curitemname"))
Call
itmquantity.appendtotextlist(Source.fieldgettext("curquantity"))
Call itmrate.appendtotextlist(Source.fieldgettext("currate"))

End If

Case "1"
'Edit function
varitemname=doc.itemname
varquantity=doc.quantity
varrate=doc.rate

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close