Saturday, December 31, 2011
Friday, December 30, 2011
Useful Shortcut in Notes - Logoff and Navigation
Ctrl+f5- Logoff notes environment
Ctrl+f8- Navigation in client and Designer too
Excel Graph in Lotus Notes
Step1:
create form and give name as “frmexcelchart” and make sure the form contains rich text field , which name is chart
step2:
create action button on which view you want to get chart…. make sure all field map in view. and put the following code in that button
Sub Click(Source As Button)
On Error Resume Next
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim view As NotesView
Dim uidoc As NotesuiDocument
Dim xlApp As Variant
Dim i As Integer
Dim j As Integer
Set view=session.CurrentDatabase.GetView(”vwStudentMark”)
Set xlApp = CreateObject(”Excel.application”)
xlApp.Visible = False
xlApp.Workbooks.Add
For i=1 To view.ColumnCount
j=1
Forall x In view.GetColumnValues(i-1)
xlapp.cells(j,i+1)=x
j=j+1
End Forall
Next
Xlapp.cells.select
Xlapp.charts.Add
Const xlLocationAsObject = 2
With xlApp.ActiveWorkbook.ActiveChart
.Name = “Student Mark system”
.HasTitle = True
.Axes(2).HasTitle = True
.Axes(2).AxisTitle.Characters.Text = “Mark”
.Axes(1).HasTitle = True
.Axes(1).AxisTitle.Characters.Text = “Student Name”
.HasLegend = True
.ChartTitle.Text = “Student Mark Chart”
.ChartType = “98″
.PlotArea.Interior.ColorIndex = “0″
.Location xlLocationAsObject, “Student Mark System” ‘move chart to worksheet
End With
xlApp.ActiveSheet.ChartObjects(”Chart 1″).Activate
xlApp.ActiveChart.ChartArea.Select
xlApp.ActiveChart.ChartArea.Copy
Set uidoc = workspace.ComposeDocument(”",”",”frmexcelchart”)
Call uidoc.GotoField(”chart”)
Call uidoc.Paste
xlApp.ActiveWorkbook.saved = True
xlApp.quit
End Sub
step3:
Save , run then click button, you can get graph
Create document from Text file in Lotus Notes
This article about import data from txt document .
Step 1:
create one .txt document like below.
“mahendran”,”9003544190″
“Ramya”,”9948484884″
“krishna”, “8585885858″
and save name as test
Step 2:
create one form and name as “mahe” and create two field (i) name1 (II) mobile
save the form and map this form to one view and also map field to columns
Step3:
create one lotus script agent and paste following code
Option Public
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim uiws As New NotesUIWorkspace
Dim fileCSV As Variant
‘Declare variables to hold data
Dim Name1 As String
Dim mobile As String
Dim counter As Integer
Dim doc As NotesDocument
counter =0
’setup file number
filenum% = FreeFile()
‘Ask user for file location
fileCSV = uiws.OpenFileDialog(False, “Choose the CSV file”,”*.txt” ,”c:\temp”)
‘If the user chose a file then process
If Not IsEmpty(fileCSV ) Then
Open fileCSV(0) For Input As filenum%
Do Until EOF(filenum%)
‘Read a line of data
Input #filenum%, name1, mobile
‘Create Notes document and write values to it
Set doc = db.CreateDocument
With doc
.name1=name1
.mobile=mobile
.form=”mahe”
End With
’save document
Call doc.save(False, False)
counter = counter +1
Loop
MsgBox “You imported ” & counter & ” records.”
End If
End Sub
Step 4:
run the agent and select test.txt and go back to view you can see imported file
dojo introduction
Hide control using Css style
dijit.Dialog in Dojo
Here i given example for how you increase your Dojo dialog Size and add title.
Souce code:
<?xml version=”1.0″ encoding=”UTF-8″?>
<xp:view xmlns:xp=”http://www.ibm.com/xsp/core” dojoParseOnLoad=”true”
dojoTheme=”true”>
<xp:this.resources>
<xp:dojoModule name=”dijit.Dialog” ></xp:dojoModule>
</xp:this.resources>
<div dojoType=”dijit.Dialog” id=”test” title= “My Dialog” style= “width: 300px ;height:200px”>
<xp:label value=”Test Dialog create by dojo” id=”label1″></xp:label>
</div>
<xp:button value=”Label” id=”button1″>
<xp:eventHandler event=”onclick” submit=”false”>
<xp:this.script><![CDATA[dijit.byId("test").show()]]></xp:this.script>
</xp:eventHandler></xp:button></xp:view>
<?xml version=”1.0″ encoding=”UTF-8″?>
<xp:view xmlns:xp=”http://www.ibm.com/xsp/core” dojoParseOnLoad=”true”
dojoTheme=”true”>
<xp:this.resources>
<xp:dojoModule name=”dijit.Dialog” ></xp:dojoModule>
</xp:this.resources>
<div dojoType=”dijit.Dialog” id=”test” title= “My Dialog” style= “width: 300px ;height:200px”>
<xp:label value=”Test Dialog create by dojo” id=”label1″></xp:label>
</div>
<xp:button value=”Label” id=”button1″>
<xp:eventHandler event=”onclick” submit=”false”>
<xp:this.script><![CDATA[dijit.byId("test").show()]]></xp:this.script>
</xp:eventHandler></xp:button></xp:view>
Explanantion:
Title attribute used for add title to dojo dialog and style attribute used for alignment and size
Creating a New Symphony Document using LotusScript
Step 1: Just create a new form an create an actions and name it as “Generate Symphony Document”.
Step 2: Then include Lotusscript Source(LSS) file in options as follows,
%INCLUDE “symphonylsx.lss”
Step 3: Now you can access the Lotus Symphony classes.
Step 4: Now write the following code in the action.
Sub Click(Source As Button)
On Error Goto errorHandler
Dim symdoc As SymphonyApplication
Set symdoc = New SymphonyApplication
Dim documents As SymphonyDocuments
Set documents = symdoc.Documents
Dim document As SymphonyDocument
Set document = documents.AddDocument(”",True,True) ‘ Syntax is below
‘Set document = documents.AddDocument(Template, AsTemplate, Visible)
Dim range As SymphonyTextRange
Set range = document.Content.End
Call range.InsertBefore(”My Symphony document”)
Exit Sub
errorHandler:
Msgbox “Error “& Chr(34) & Error() & Chr(34) & ” on Line number ” & Erl()
Exit Sub
End Sub
Step 5: Now preview the form and click the action button. A new symphony document will open and “My Symphony document” is written in that document.
Note : If you want the properties and methods of the symphony class, for help see the reference tab in left side of the programming pane while writing code.
We will discuss more about this in next post.
Anotomy of Note ID
Actual Note Id information of a document will be displayed as follows,
ID: OF0000039D:3836C29F-ON85255DC9:0056FB94
SD00255DF4:0057B8FA-SN00000003
DB85255CD9:00567287-NT0000C092
There are 6 parts in note ID. They are
1. UNID (Universal Note ID)
UNID consists of originator File and originator note.(1st Line)
- Universal Note ID (UNID) =
ID: OF0000039D:3836C29F-ON85255DC9:0056FB94
SD00255DF4:0057B8FA-SN00000003
DB85255CD9:00567287-NT0000C092
Every replica of a note has the same UNID, and the UNID does not change when a note is modified.
2. OID (Originator ID)
OID = UNID + Sequence No and Sequence Time
- Originator ID (OID) =
ID: OF0000039D:3836C29F-ON85255DC9:0056FB94
SD00255DF4:0057B8FA-SN00000003
DB85255CD9:00567287-NT0000C092
Every replica of a note has the same OID, but the OID changes when the note is modified.
The changes will occur only in Sequence No and Sequence Time part not in UNID.
3. NID (Note ID)
Note ID =
ID: OF0000039D:3836C29F-ON85255DC9:0056FB94
SD00255DF4:0057B8FA-SN00000003
DB85255CD9:00567287-NT0000C092
The NID does not contain information about the database being referred to, and it does not change when the note is modified.
4. GNID (Global Note ID)
GNID = Database ID + NID
- Global Note ID (GNID) =
ID: OF0000039D:3836C29F-ON85255DC9:0056FB94
SD00255DF4:0057B8FA-SN00000003
DB85255CD9:00567287-NT0000C092
The GNID does not change as the note is modified. The GNIDs of replica copies of a note will probably be different, since the various copies will occupy different positions in their databases.
5. IID (Instance ID)
The Instance ID consists of the note’s modification TIMEDATE and the note ID.
The IID does not contain information about the database being referred to. The IID changes when the note is modified
6. GIID (Global Instance ID)
The GIID contains information about the database being referred to. The GIID changes when the note is modified
$V2AttachmentOptions - Reserve field
When we are saving a document with attachments, the attachments will be visible in the bottom of the document on both web and in client.
Its not a good manner to show attachments in the bottom of the document. So we want to hide the attachment.
A reserved field is used to hide the attachments. That field is “$V2AttachmentOptions”.
If value = “0″ –> not to display attachment icons
Note: Most of the times this will not work so follow the following method to hide the attachment icons.
Place
Creating New Files using Lotus Script Freefile()
There is a excellent way to create a new file of our own in any type using LotusScript.
Eg: We can create any type of file just by changing the extension of the file name.
Here is the sample code to create a file using lotusScript.
Dim ses As New NotesSession
Dim fileNum As Integer
Dim fileName As String
fileNum% = Freefile()
fileName$ = ses.GetEnvironmentString(”Directory”,True) +”\test.txt”
Open fileName$ For Output As fileNum%
Print #fileNum%, “I have created a new text file”
Exit Sub
We can also create a word/Excel/Rich Text File/* by changing the extension as .doc/.xls/.rtf/.*
I think its very useful for you legends to go ahead.
$Formulaclass- Reservefield
We know that, we can see the saved documents in database in views.
Is there any chance to view all design elements in a single view?
Yes, we can view those design elements in view by changing the value of reserved field.
Hint: Fields name start with $ be the reserve field.
In view there is a reserve field called $FormulaClass. As default its value is 1. If the value is 1, it shows only the saved documents in the view.
Value of $FormulaClass Viewing Elements
1 Documents
4 Forms and Subforms
8 Views, Folders and Navigators
16 Database Title
32 Design Collection
64 ACL Note (in compiled format)
512 Agents (Shared)
1024 Shared Fields
1548 Forms, Sub-forms, Views, Folders, Navigators, Agents(Shared), Shared Fields
If we change the value of &FormulaClass into 1548(sum of 4 + 8 + 512 + 1024) it shows all Forms, Sub-forms, Views, Folders, Navigators, Agents (Shared), Shared Fields.
For Example: Follow the below steps to get clear idea on that.
Step 1: Create a new view named as “ViewDesignElements”(user defined name) and give “SELECT @All” as view selection formula in programming pane.
Step 2: Create two columns and name as “Design Element Type” & “Design Element Name”.
Step 3: For “Design Element Name” column give “$Title” as formula for column value. And categorize “Design Element Type” column.
Step 4 : Then create an LotusScript Agent and name it as “designAgent”.
Step 5 : Type the following code in Initialize of the agent.
This script is to change the value of “$FormulaClass”.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view= db.GetView(”ViewDesignElements”)
Set doc = db.GetDocumentByUNID(view.UniversalID)
Call doc.ReplaceItemValue(”$FormulaClass”, “1548″)
doc.Save True, True
End Sub
Step 6 : Create an action button in the view to run the agent by event. Now enter the following code for action button.
@Command([ToolsRunMacro];”designAgent”)
Step 7 : Now Preview the view and click the action button. It will run agent and changes the $FormulaClass value as 1548 to view all design elements.
Step 8 : Then press Shift + F9 to refresh. It will show all the design elements.
Field Validation in AJAX in an Efficient Manner
Here is a simple way to validate mandatory fields, if they a more. Don’t waste your time to write a separate code for each and every fields.
I have done a simple validation in javascript for checking that the field not be null.
Step 1: Create a hidden field and name it as of your wish (name of the field may be “MandatoryFields”).
Step 2: Give all the mandatory field names with comma separator as the default value of the hidden field as shown below.
Step 3: Put the following function in JSHeader.
function validateSupplier()
{
var f=document.forms[0];
var fieldsString= f.MandatoryFields.value;
var MandatoryFields = fieldsString.split(”,”);
var ValidatedFields=0;
for(var i=0; i
{
var fieldValue = eval(’f.’+Ma ndatoryFields [i]+’.value’);
if(trim(fieldValue)==”")
{
alert(”Please fill all the mandatory fields for Supplier Information”);
eval(’f.’+MandatoryFields[i]+’.focus()’);
return false;
break;
}
else
{
ValidatedFields=ValidatedFields+1;
if(ValidatedFields==MandatoryFields.length)
{
return true;
}
}
}
}
/* Function used to trim string */
function trim(str)
{
if(!str || typeof str != ’string’)
return “”;
return str.replace(/^[\s]+/,”).replace(/[\s]+$/,”).replace(/[\s]{2,}/,’ ‘);
}
/********** Trim Ends *******/
Step 4: Write the following code in “onclick()” of a submit button.
var success = validateSupplier();
if(success)
{
document.forms[0].submit();
}
Its the smarter way to validate similar validation for multiple fields.
We can also validate for the datatypes in the same way.
function validateSupplier()
{
var f=document.forms[0];
var fieldsString= f.MandatoryFields.value;
var MandatoryFields = fieldsString.split(”,”);
var ValidatedFields=0;
for(var i=0; i
{
var fieldValue = eval(’f.’+MandatoryFields[i]+’.value’);
if(trim(fieldValue)==”")
{
alert(”Please fill all the mandatory fields for Supplier Information”);
eval(’f.’+MandatoryFields[i]+’.focus()’);
return false;
break;
}
else
{
ValidatedFields=ValidatedFields+1;
if(ValidatedFields==MandatoryFields.length)
{
return true;
}
}
}
}
/* Function used to trim string */
function trim(str)
{
if(!str || typeof str != ’string’)
return “”;
return str.replace(/^[\s]+/,”).replace(/[\s]+$/,”).replace(/[\s]{2,}/,’ ‘);
}
/********** Trim Ends *******/
Step 4: Write the following code in “onclick()” of a submit button.
var success = validateSupplier();
if(success)
{
document.forms[0].submit();
}
Its the smarter way to validate similar validation for multiple fields.
We can also validate for the datatypes in the same way.
Export all view data to Symphony SpreadSheet(.ods) from Web
Create a button and call the following agent in onclick() of that button.
Note : For better output you have to map all required fields in the view.
Sub Initialize
On Error GoTo errorHandler
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim stuDetailsView As NotesView
Dim viewEntryCollection As NotesViewEntryCollection
Dim viewEntry As NotesViewEntry
Dim fileName As String
Dim i As Integer
Dim j As Integer
Dim cnam As Variant
Set db = session.CurrentDatabase
Set stuDetailsView = db.GetView(”vwStudent”)
‘Assign ‘vwStudent’ view as NotesView
Set viewEntryCollection = stuDetailsView.AllEntries
‘ViewEntryCollection contains the handle of all documents in the view
Set viewEntry = viewEntryCollection.GetFirstEntry
‘View Entry have the handle of first document from the ViewEntryCollection
fileName = “Web All Documents.ods”
‘File name of the Symphony spreadsheet with ‘ods’ extension
Print |Content-Type:application/Lotus Symphony Spreadsheet in Lotus Notes.exe|
Print |Content-Disposition: Attachment; fileName=”|+fileName+|”|
‘To display a prompt to user to save or open
Print “
”‘Writing into the spreadsheet and creating/opening a table
Print “
”‘Writes the Column header in the first row
For j=1 To stuDetailsView.EntryCount
‘Loop runs for all documents in the view and exits
Print “
”For i=0 To stuDetailsView.ColumnCount-1
‘Loop runs for all columns in the each documents in the view
Print “
”‘Writes all column values in the spreadsheet corresponding to the view
Next i
Set viewEntry=viewEntryCollection.GetNextEntry(viewEntry)
‘ Getting the next entry from the collection
Print “
”Next j
Print “
Student Name | Student RegNo | Date of Birth | Department | Batch | College Name |
” & viewEntry.ColumnValues(i) & “ |
Exit Sub
errorHandler:
Print “Error :” & Error() & “Line No :” & Erl()
‘ Prints the error and the line number where the error occurs
Exit Sub
End Sub
Export all view data to Symphony SpreadSheet (.ods) from Notes
Call the following agent in an action button to export selected documents in the view to symphony Spreadsheet.
Note : For better output you have to map all required fields in the view. And it will also ask the path to save the file which contains the exported data.
Sub Initialize
On Error GoTo errorHandler
Dim ses As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim stuDetailsView As NotesView
Dim viewEntryCollection As NotesViewEntryCollection
Dim viewEntry As NotesViewEntry
Dim i As Integer
Dim j As integer
Dim cnam As Variant
Set db = ses.CurrentDatabase
Set stuDetailsView=db.GetView(”vwStudent”)
‘Assign ‘vwStudent’ view as NotesView
Set viewEntryCollection=stuDetailsView.AllEntries
‘ViewEntryCollection contains the handle of all documents in the view
Set viewEntry=viewEntryCollection.GetFirstEntry
‘View Entry have the handle of first document from the ViewEntryCollection
Dim fileNum As Integer
Dim fileName As String
fileNum = FreeFile()
‘Gives a file number between 0 to 255 which is currently free
Dim saveas As Variant
saveas = ws.SavefileDialog(False,,”Symphony Word | *.odt”,,”All Documents To Symphony Word.odt”)
‘Opens a file save dialog box and ask user where to save the Created document, The file name is default
If IsEmpty(saveas) Then
Exit sub
End If
fileName = saveas(0)
‘Assigning the filename with full path which is given by the user
Open fileName For Output As fileNum
‘Opens the created file with reference to the file number and ready to write in it
Print #fileNum,”
Student Details
‘ Document heading
Print #fileNum,”
‘Creates a table in center of the Symphony Document
Print #fileNum,”
”‘Writes the Column header in the first row of the table
For j=1 To stuDetailsView.EntryCount
‘Loop runs for all documents in the view and exits
Print #fileNum,”
”For i=0 To stuDetailsView.ColumnCount-1
‘Loop runs for all columns in the each documents in the view
Print #fileNum, “
”‘Writes all column values inside the table in the documents corresponding to the view
Next i
Set viewEntry=viewEntryCollection.GetNextEntry(viewEntry)
‘ Getting the next entry from the collection
Print #fileNum,”
”Next j
Print #fileNum,”
Student Name | Student RegNo | Date of Birth | Department | Batch | College Name |
---|---|---|---|---|---|
” & viewEntry.ColumnValues(i) & “ |
‘Closes the table
Close fileNum
Print “Symphony Document Report Generated Successfully”
‘Displays this message in the status bar
Exit Sub
errorHandler:
MsgBox “Line No :” & Erl()& Chr(13) &”Error : ” & Error()
‘ Prints the error and the line number where the error occurs
Exit Sub
End Sub
@DbColumn and @DbLookup in AJAX
Its very simple and easier get DBColumn and DBLookup using AJAX.
Click the following link for more details and full code.
http://www.antcer.it/lotus-domino/dbcolumn-e-dblookup-usando-ajax/
Adding New Record : ODBC Connection in Notes
It is similar to creating ODBC connection in java.
Create a agent for Adding new record to MS-Access
Step1: Create a connection to ODBC for accessing database.
Step2: Mention the name of the table and get a query for insert record.
step3: Call this agent from view.
Sample coding:
Dim con As New ODBCConnection ‘ Declare con object for connect to database.
Dim qry As New ODBCQuery ‘Declare qry variable as ODBCQuery
Dim res As New ODBCResultSet ‘Declare res for get the records
Dim i As Integer
Dim b As Boolean
If Con.ConnectTo(”DBs”) Then ‘Here create a connection to data source
Set Qry.Connection = Con
Qry.SQL = “select * from stdu1″ ‘Create a query for get all records from table
Set Res.Query = Qry
Res.Execute
addnew:
Res.addrow ‘Create a object for adding new record
‘Add new value to specified Column
Call res.Setvalue(”RollNo”,CInt(InputBox(”Enter Roll No”,”")))
Call res.setvalue(”Name”,InputBox(”Enter name”,”"))
MsgBox (”The given row was succesfully added.”)
Call res.Updaterow() ‘Here refresh the table after adding new values
i=ws.Prompt(2, “New Record”, “Do you want to add new record”)
If i=1 Then
GoTo addnew ‘User want to add new record again then repeat the above processes
End If
Res.Close(DB_Close) ‘Close the result set
con.DisConnect ‘Here disconnect the existing connection
Else
MessageBox (”Could not connect to data source”)
End If
Edit document via its view column entries
It is simple and a very useful when allow user to edit document by caret id of current document through view entries. There is no need opening document in edit mode.
Setp 1:
First Select the columns that will display the editable fields.
Setp 2:
Then choose the design of column properties box and check “Editable column” on the Info tab of the column properties box.
Setp 3:
Goto Inviewedit event in the Programmer’s pane and then type the following coding.
Coding:
Declare and Define constants for request types
Const QUERY_REQUEST = 1 ‘Declare constant for requesting the query to view when user enter the editable column
Const VALIDATE_REQUEST = 2 ‘Validate the current field is editable or not
Const SAVE_REQUEST = 3 ‘Update the editaed values after validation on existing document
Const NEWENTRY_REQUEST = 4 ‘Add enries to new document
‘Declare the neccesscery variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String ‘Variable for getting carret id of currently pointing document
caret = Source.CaretNoteID ‘Get the CaretNoteID
If caret = “0″ Then Exit Sub ‘ exit if it does not point at document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret) ‘ Get the current database and document
Select Case Requesttype ‘Here select the type of request
Case VALIDATE_REQUEST ‘Validate when user tries to save document with no value
If Fulltrim(Columnvalue(0)) = “” Then
Messagebox “You must enter a value”,, “No value in column”
Continue = False
End If
Case SAVE_REQUEST ‘Check the save mode
For i = 0 To Ubound(Colprogname) Step 1
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
Next
Call doc.Save(True, True, True)
Iterator methods for Java
This is one of the most useful interface in java collection framework. It is similar to vector but it is unsynchronized .
Also it is similar to Enumeration in the Java collections framework. But it differ from enumerations in two ways
Iterators allows the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
There are powerful methods for traversing elements.
Methods:
hasNext()
next()
remove()
Stpes:
1. First, obtain iterator to the start of the collection by calling the collection’s iterator( ) method
2. Then call the hasNext( ) method to find wethear nest item is available or not.
3. Finally, within the loop, obtain each element by calling next( ).
ListIterator
With help of this class traverse the elements in both ways, modify & adding new element in list during iteration, and obtain the iterator’s current position in the list.
Additional methods:
hasPrevious()
previous()
nextIndex()
previousIndex()
Excluding Saturday and Sunday from given two dates
Hi gus, with help of business days you easily find number days between two dates. But x-pages doesn’t support business day. So this is useful by the following java script and @formulas coding:
Step 1: Get the starting and ending date.
Step 2: Find total number of days between this two days
Step 3: Divide the result value in step2 by 7 and then multiply this value by 2
Step :4 Subtract this value from total days
Coding:
var sd=getComponent(”StartDate”).getValue(); // Starting date
var ed=getComponent(”EndDate”).getValue(); //Ending date
var weekdays=0;
var days=@Day(ed)-@Day(sd);
if(@Month(sd)==”1.0″ || @Month(sd)==”3.0″ ||@Month(sd)==”5.0″ ||@Month(sd)==”7.0″ ||@Month(sd)==”8.0″ ||@Month(sd)==”10.0″ ||@Month(sd)==”12.0″)
//To find number days between two give dates
var months=(@Month(ed)-@Month(sd))*31;
if(@Month(sd)==”4.0″ || @Month(sd)==”6.0″ ||@Month(sd)==”9.0″ ||@Month(sd)==”11.0″)
var months=(@Month(ed)-@Month(sd))*30;
if(@Month(sd)==”2.0″)
var months=@Month(sd)*28;
if(@Year(sd)%4==0) //If the give is year is leaf year
var years=(@Year(ed)-@Year(sd))*366;
else //Ordinary Year
var years=(@Year(ed)-@Year(sd))*365;
var tdays=days+months+years+1; //Total days
if(tdays>=7)
weekdays=Math.floor(tdays/7); //Calculate number of weeks
var ds=tdays-(weekdays*2); //number of days excluding Week start and end dates
getComponent(”Duration”).setValue(ds);
Repeat control with Multi values for Field
Hi Guys, i want to share discussion about how to use repeat controls. Here i show small example and use java expression syntax. I got some idea about binding java objects to fields.
Step1: Create a form and give name as Test, Create a editable field inside this form as field.
Step2: Then create a one x-page. Place the one repeat control and button and then place the following code in onclick event of this button and will show the result.
Code:
var field = document.getValue( ‘field’ );
if( !field ){ field = []; }
if( typeof field === ’string’ ){
field = [ field ];
}
field.push(”);
document.setValue( ‘field’, field );
Count number of seelcted documents and alter the entries in xpages
Add a new Document using Dojo
Dojo is toolkit for creating dynamic web user interfaces. Here i save new document with help of dojo popup.
Step 1: Select Xpage-> All Properties->Dojo -> Set the values of dojoParseOnLoad and dojoTheme as True.
Step 2: Create server java script and place the following code:
function dialog_create(dojoid, Popuptitle) {
var dialogWidget = dijit.byId(dojoid);
if( dialogWidget )
dialogWidget.destroyRecursive(true);
dialogWidget = new dijit.Dialog({
title: Popuptitle, duration:600},
dojo.byId(dojoid));
var dialog = dojo.byId(dojoid);
dialog.parentNode.removeChild(dialog);
var form = document.forms[0];
form.appendChild(dialog);
}
step 3: Select Xpage-> Resources-> Add this create script.
step 4: Within div tag, create the some fields and set id name as “Add” and Create one button for save the document.
step 5: Then On click event of Save button, write the code: dijit.byId(”Add”).show()
step 6: The preview this page in web browser and then see the result.
How to clear a Java Error Using Java code in Notes
ClearJavaError: It is one of the java object for clearing all
error while trying to get a specific java class. The user want
to get all the error informations then all java errors are
cleared with help of this object.
Code:
Dim jclass As JavaClass
Dim jrror As JavaError
On Error GoTo Catch
Set mySession = new JavaSession()
Set jclass = mySession.GetClass(”javaClass”)
exit Sub
Catch:
Set jerror = mySession.getLastJavaError()
MessageBox jerror.errormsg,, “Error”
mySession.ClearJavaError
View Panel - Filtering column
Where i learn this stuff?
I want to display information about current user only. But i
got conflict that is i saw information about all users. At that
time i got idea about filter by column in view panel.
Step1 : Select the view panel->properties->Add Data Source
Step 2: In Data Option, select-> Filetr By Category Name->Click on diamond symbol-Select->Computed value
Setp 3: Then add condition. Here i use current user as the
filtering value. @Name(”[CN]“,context.getUser().getFullName());
Sending NotesDocument Link in Notes and Web
Here i want share about how to send document link to mail by document universal id.
Step 1: Create one document for send mail and add the following necessary fields: Form, From, Memo, SendTo and Subject.
Step 2: Save the data source and then get that universal id of that document
Step 3: finally add this id to body.
var Sender=”Ram Kumar”;
var Receiver=”kramkumar.mca@gmail.com”
var Subject;
var DocUNID = LeaveRequest.getDocument().getUniversalID();
var SendingxPage = “LeaveRequest.xsp”;
mailDoc=database.createDocument();
mailDoc.appendItemValue(”Form”,”Memo”);
mailDoc.appendItemValue(”From”,Sender);
Subject=” To be Approved”;
mailDoc.appendItemValue(”Subject”,Subject);
var rtItem=mailDoc.createRichTextItem(”Body”);
var serverName=session.getServerName();
var DBPath=session.getDatabase();
var dbFullAddressNotes = serverName + “/” + DBPath;
rtItem.appendText (”Hi “+Receiver+”,”)
rtItem.addNewLine(2)
rtItem.addTab (1)
//On Notes var url=”notes://”+dbFullAddressNotes+”/”+LRxPage+ “?OpenXPage&documentId=”+DocUNID+ “&action=editDocument”;
//On Web Browser var weburl=”http://”+ serverName +”.maargasystems.local”+”/”+DBPath+” /”+SendingXPage+ “?OpenXPage&documentId=”+LRUNID+ “&action=editDocument”;
rtItem.appendText(” Please click on the below link to approve my request:”)
rtItem.addNewLine(1)
rtItem.appendText(”On Notes: “+url)
rtItem.addNewLine(1)
rtItem.appendText(”On Browser “+weburl)
rtItem.update()
mailDoc.appendItemValue(”SendTo”,Receiver);
mailDoc.send(false)
Java File Reader and File Writer
Here i want to discuss about how to read data from a file and
to append that content to another file by java program. Here
i use FileReader class for reading content from file and FileWriter
for append data to file. Also BufferedReader class is used to
getting input from keyboard at run time.
Coding:
import java.io.*;
public class DemoFileCreation{
public static void main(String[] args) throws IOException {
FileReader inputStream = null;
FileWriter outputStream = null;
BufferedReader dataIn = new BufferedReader( new InputStreamReader(System.in) );
System.out.println(”Enter Roll No:”);
String sno=dataIn.readLine();
System.out.println(”Enter Name:”);
String name=dataIn.readLine();
try {
File f=new File(”demo.txt”);
if(!f.exists())
{
f.createNewFile();
}
inputStream = new FileReader(f);
outputStream = new FileWriter(”characteroutput.doc”,true);
outputStream.write(”\n”);
outputStream.write(”Roll No: “+sno);
outputStream.write(”\tName: “+name);
}
finally {
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
}
}
User Defined Data types in Lotus Script [Like Structure]
In lotus script, types is collection more than one data variables that can be manipulated as a single unit.
It is similar to structure in c and used to store database records within LotusScript.
These members are declared without Dim keyword.
Here i describing how to create type and use by the below example:
——————————————-
TYPE Data1
EmpID As number
EmpName As STRING
Doj As DateTime
END TYPE
——————————————–
Now the following declaration descrips how to use members of Data1 by (.) operator
Dim employee as Data1
emploee.EmpId=7615
employee.EmpName=”Ram”
employee.Doj=”08/11/2010″
Listbox Elements manipulation [Move Up and Down]
Here i want to share about how to move items in list box by up and down direction.
Setp 1:
Create one script library as java script and add the following function
function move(item,direction)
{
var listbox = item;
var direction=direction;
var selIndex = listbox.selectedIndex;
if(-1 == selIndex) {
alert(”Please select an option to move.”);
return;
}
var increment = -1;
if(direction == ‘up’)
increment = -1;
else
increment = 1;
if((selIndex + increment) < 0 ||
(selIndex + increment) > (listbox.options.length-1)) {
return;
}
var selValue = listbox.options[selIndex].value;
var selText = listbox.options[selIndex].text;
listbox.options[selIndex].value = listbox.options[selIndex + increment].value
listbox.options[selIndex].text = listbox.options[selIndex + increment].text
listbox.options[selIndex + increment].value = selValue;
listbox.options[selIndex + increment].text = selText;
listbox.selectedIndex = selIndex + increment;
}
step 2:
Create new xpage ->Select Page->Properties-> In resource, add the java script.
Step 3:
Then place one list box and add some values and two buttons and call this function as
In Up button,
var listbox = document.getElementById(”#{id:list}”);
var direction=”up”;
move(listbox,direction);
In Down Button,
var listbox = document.getElementById(”#{id:list}”);
var direction=”down”;
move(listbox,direction);
Step 3:
Then preview this xpage and show the result.
Dojo Tooltip
This is one of the feature of dojo and simple. It is similar to help button and used to design the web pages attractively.
Step 1 : Create one xpage and add some control to that page.
Here i use one button for testing purpose.
Step 2: Add the dijit.Tooltip module in Xpage Resources.
Step 3: Then select source and the following tag within
“This is a button”>
Launching application via Lotus Script
Start new process or application from notes client
In lotus script, by calling the Shell(”processname”) method.
Syntax:
Shell ( processName[ , windowStyle ] )
Example:
Dim i As Integer
i=Shell(”calc.exe”)
———————————————————————————————–
In formula, by calling execute command
Syntax:
@Command( [Execute] ; application ; fileNames )
Example:
@Command( [Execute];”Admin”)
JUNIT testing
Batch file Creation
How to stop a running thread
XSLT and XML
XSL,XSLT,XSL-FO and XML
(eXtensible Stylesheet Language) A style sheet standard from the W3C that is used to convert an XML document into many formats for publishing and printing. XSL is similar to the Cascading Style Sheets (CSS) in HTML and is compatible with CSS2. An XML document is converted by an "XSLT Processor," also called an "XSLT Transformation Engine," into the new format based on three sets of XSL description languages, as follows: