Friday, January 29, 2010

#5 : Bugs I Found : Work around for doc.AppendItemValue command

First in order to understand issues with the "AppendItemValue" command in the NotesDocument Class, you may have to refer to the following post
http://ozinisle.blogspot.com/2010/01/3-bugs-i-found-issues-with-lotusscript.html

The work around would be to use the NotesItem class and its "AppendToTextList" command as illustrated below

    Set item = source.Document.GetFirstItem("MultiValuedField")
    Call item.AppendToTextList(rooms)


:)

Thursday, January 28, 2010

Trigger onclick event of a button in lotus notes client

Ever thought of how to trigger a button onclick event using javascript in Notes Client.... I have been through these night mares when I first learnt javascript and then application development in notes client.

Practically I never crossed this scenario and i wont recommend relying on this as well... unless you are to sure that u have no other go...

The idea behind this experiment is to trigger a formula popup using a javascript coded button in Notes Client. The following are the details of my experiment.

1. Create a form and add two buttons to it namely, "Formula Button" and "Javascript Button".

2.Now in the HTML properties of the button named "Formula Button", give the name as "formulaButton" and put the formula @Prompt(1;"";"Success") in the click event of the formula button

 
3.Now click the button named "Javascript Button", in the onclick event of the button, choose the Run properties as "Client" and "Javascript" and put in the following code "document.forms[0].formulaButton.click()"

 
4.Now save, preview the form in notes client and click the javascript button.
This will bring up a prompt saying "Success". This indicates that the formula popup associated with the Formula Button is triggered by the javascript code in the "Javascript Button" in Notes Client...

Hope this is use ful

Open database Dialog - Lotusscript - In Action

The following is a reusable fragment of work which can be used in various applications to help user choose databases and get their details of their file path and server name, instead of typing them explicitly in fields.

Following is a procedure that will illustrate the usage of open database dialog triggered using lotus script.

1. Create a lotus notes form, add a check box and a couple of fields as found in the following image



In the on exiting event of the check box put the following code(change the parameters values to suit your field names)

Call getDBFile("checkboxName","serverFieldName","dBPathFieldName")

 2. Now check the "Run Exiting/OnChange events after value change" checkbox in the advanced tab of the check box properties as mentioned below

3.  Copy the following function and add it to your form global or where ever you can call it from

Function getDBFile(chkField As String,dbServerField As String,dbPathfield As String) As Boolean
   
    'mark the flow of control moving inside the current function
    getDBFile=False
   
    'declare all variables and objects necessary for further manipulation
    Dim workspace As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim uidoc As NotesUIDocument
    Dim currDoc As NotesDocument
    Dim currDB As NotesDatabase
    Dim dbServer As NotesName
   
    Dim selectedValue As String
    Dim empDBObj As Variant
   
    'handle errors in case of abrupt termination
    On Error Goto errHandler
   
   
    'set the handle of the current document
    Set uidoc = workspace.CurrentDocument
   
    'set the back end handle of the current document
    Set currDoc=uidoc.Document
   
   
    'if the selected value is of type 1 then ask the user to chose a database and populate the choosen db's
    'server and file path into the server and database path field
    selectedValue=currDoc.getitemvalue(chkField)(0)
    If selectedValue<>"1" Then Exit Function
   
    empDBObj= workspace.Prompt(13,"Database List","Choose Employee Database")
    If Not Isempty(empDBObj) Then
        Set dbServer=session.CreateName(empDBObj(0))
        Call currDoc.ReplaceItemValue(dbServerField,dbServer.Abbreviated)
        Call currDoc.ReplaceItemValue(dbPathfield,empDBObj(1))       
    End If
   
    Call currDoc.replaceitemvalue(chkField,"")
   
    getDBFile=True
    Exit Function
    'log the error that resulted in abrupt termination of the process
errHandler:
    Print "Error ***" & Error & "*** occured on line ***" & Cstr(Erl) & "*** with error number ***"   _
    & Cstr(Err) & "*** in ""Globals"" in form ""Database Configuration"""
    Exit Function
End Function


4. Now save and preview the form in Notes Client. Once the form is open in the notes client click the check box.
This will bring up the open database dialog as indicated below,

5. Choose your database and click open on the dialog box. This will automatically populate the databases in the empty fields as follows,


Monday, January 25, 2010

#4: Bugs I found : Issues with lotusscript ComputeWithForm command

I sort of understand the "ComputeWithForm" command in the "NotesDocument" class as a command that refreshes a document in the back end.

It works most of the time, but for one scenario that I came across.And that is as follows

I have a view with say 1000 documents.
I am opening the form using which I have created those documents in the designer
And am adding a computed field with a @DBLookUp Formula
Then I am creating a new column on the view and mapping this computed field
Now I am creating an action button in the view and am coding the following into that,

 dim ws a new notesuiworkspace
 dim s as new notessession
 dim currDB as notesdatabase
 dim dc as notesdocumentcollection
 dim doc as notesdocument

 set currDB=s.currentdatabase
 set dc=currDB.unprocesseddocuments
 set doc=dc.getfirstdocument

 while not doc is nothing
  call doc.computewithform(true,false)
  call doc.save(true,false)
 wend

 call ws.currentview.refresh

So when I select a few document and click the action button I should see the newly added column showing the newly added computed field on the document. But No I dont see any values yet.

But when I open the document, edit the same, save and close it manually, I am able to see the differences on the view.

Yes doc.ComputeWithForm has failed in this scenario and the fix to this is to use @Command([ToolsRefreshAllDocs])

#3 : bugs I found : issues with lotusscript appendItemValue

The lotusscript command, named "AppendItemValue" in the class "NotesDocument" is supposed to work like, "FieldAppendText" in the "NotesUIDocument" class. I believe I am right here.

Yes I started a fragment of code with the same belief and found some beautiful results. Yes I could have never arrived at that with out this beautiful worthless command.

Let me make myself clear with the following procedure.

1.Let me say I have got a field named as "MyField" in a document.
2.Now I say, doc.AppendItemValue("MyField","New Value").
3. Say I am doing it for say 3 times and am saving the document

The expected result is, say if the old value of the field is "Old Value" then the result cos of above process must be "Old ValueNew ValueNew ValueNewValue".
4. But the results are very inconsistent and random.
The following is one of the possible results that I will definetly obtain (I mean I will never end up with the expected result hi hi).

If you check the document properties then you would find a item named "MyField" with value "Old ValueNew Value" and two other items named "MyField" with values "New Value".

Can you do this through any other means....

AppendItemValue is awesome hi hi :O)

A possible fix to this issue is posted in the following location:
http://ozinisle.blogspot.com/2010/01/work-around-for-docappenditemvalue.html
:)

#2: Bugs I found : Issues with Radio Button with default integer value

How should I explain this....

Perhaps try the following and you will end up with funny results.

1. Create a field of type Radio button in a Lotus Notes Form

2. Give values say "A" and "B" as list values in the second tab of the field properties box

3. Now preview it in the notes client and ensure that it is looks like a radio button with values "A" and "B". No wait you are not near to the bug yet

4.Get back to the designer and assign a default value of Number 1 to the radio button. Remember it is 1 and not "1". Hope you understand the difference between the text and the number

5. Save the form and Preview the same on the browser.

6. Voila you see a text field with Number 1 in it.....

How do you explain this...? I dont have one, so I call this a bug... dare to correct me ... come on give it a shot

#1 : Bugs I found : Issues with Computed Richtext field in lotus notes

Once I was hit upon with a request where the client wanted to have a comment field as a richtext one. Upon clicking a button named as "Update Comments" the entire richtext contents in the comments field should be moved into a summary field which is again of type computed richtext.

It is something like the Audit trail.

It did work fine until I found an issue with the images which are copied and pasted from the clip board.

This is again random. It would move to the summary field for a couple of times and then it would spoil every thing.

The following is what happened,
1. moved all the attachments into the footer of the document.
2. when I close and open the document again, it would say, "A part of the document has been modified by later version of notes and cannot be open" sort of message.

I tried to find a work around using dxl etc... but each and every attempt failed.
And finally when I got my self rendered hopeless of resolving the issue, a page on the IBM site eased me.

It said that it is an issue with the Lotus Notes software itself and shall be fixed in later versions of notes.I dont think this is fixed in even Version 8.5.1

Wednesday, January 20, 2010

Simple Daily Advise Server and Client

Daily Advice Server
****************

import java.io.*;
import java.net.*;

public class DailyAdviceServer {

    /**
     * @param args
     */
   
    String[] adviceList={"one server","two server","three server","four server","five server"
            ,"six server","seven server"};
   
    public void go()    {
        try    {
            ServerSocket serverSock=new ServerSocket(4242);
            while(true)    {
                Socket sock=serverSock.accept();
                PrintWriter writer=new PrintWriter(sock.getOutputStream());
                String advice=getAdvice();
                writer.println(advice);
                writer.close();
                System.out.println(advice);
            }
        }catch (IOException ioex){
            ioex.printStackTrace();
        }
    }
   
    public String getAdvice()    {
        int random=(int)(Math.random()*adviceList.length);
        return adviceList[random];
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        DailyAdviceServer server=new DailyAdviceServer();
        server.go();
    }

}

Daily Advice Client
****************

import java.io.*;
import java.net.*;

public class DailyAdviceClient {

    /**
     * @param args
     */
    public void go()    {
        try    {
            Socket socket=new Socket("127.0.0.1",4242);
           
            InputStreamReader streamReader=new InputStreamReader(socket.getInputStream());
            BufferedReader reader=new BufferedReader(streamReader);
           
            String advice=reader.readLine();
            System.out.println("Today you should: "+advice);
           
            reader.close();
           
        }    catch(IOException ioex)    {
            ioex.printStackTrace();
        }
    }
   
   
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        DailyAdviceClient client=new DailyAdviceClient();
        client.go();

    }

}

Lotusscript code to transfer contents of one richtext field to an other

Put the following code in a button on a form and ensure that you map the relevant richtext fields in this code

    Dim  s As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim tdoc As NotesDocument
    Dim vw As NotesView   
    Dim currItem As Variant   
    Dim targetitem As Variant
    Dim seconditem As Variant   
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
   
    Set db=s.CurrentDatabase
    Set uidoc=ws.CurrentDocument
    Set doc=uidoc.Document
   
    Set vw=db.GetView("DHTMLDemo")
    Set tdoc=vw.GetFirstDocument
    If(doc.HasItem("SourceRT")) Then
        Set currItem=doc.GetFirstItem("SourceRT")
    Else
        Set currItem=doc.CreateRichTextItem("SourceRT")
    End If
   
    If(doc.HasItem("TestRT")) Then
        Set seconditem=doc.GetFirstItem("TestRT")
    Else
        Set seconditem=doc.CreateRichTextItem("TestRT")
    End If
   
    Call seconditem.AppendRTItem(currItem)   
    Call doc.Save(True,False)
    Call doc.ReplaceItemValue("SaveOptions","0")
    Call uidoc.Close
    set uidoc=ws.editdocument(true,doc)

'on the post open event of the form, put the following code
if not source.isnewdoc then
    call source.document.SaveOptions="1"
end if

Lotusscript code fragment that shall act like a on-off switch on notes documents

%Rem
    @Created 1/28/2008
    @Author  Karthikeyan.A
    @Purpose This must be included into the application being built inorder to achieve a better command over the various functionalities
    @syntax enableOrDisable(status as boolean,fieldname as string,ActiveState as string, InactiveState as string)
    @Scope: Must be put in a Script Library to achieve a global scope

Explanation: 
    (1) You must have a view indexed by the various functionality in the database
    (2) The document contained in the view must contain field,say "ActivityStatus" dedicated to hold the status information of the concerned functionality
    (3) The contents of the field must be either 0 or 1
    (4) 0-indicates that the function is disabled and 1- intdicates the function is active
    (5) Parameters
        Status- False or True
        FieldName- The name of the field that holds the status value(here it is "ActivityStatus")
        ActiveState- string that represents the active state in the field (here it is the content of "ActivityStatus")
        InactiveState- string that represents the inactive state in the field (here it is the content of "ActivityStatus")
   
%End Rem

'Declarations
'**************

Dim fieldname As String
Dim functionalitystatus As Boolean

Dim temp As String
Dim session As NotesSession

Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument

Dim ActiveState As String
Dim inactiveState As String

'code of the Function
'**********************
Function enableOrDisable(functionalitystatus,fieldname,ActiveState,InactiveState)
    On Error Goto errHandler   
'*********************
   
    'change the status code as per your specification
    'Active=1 or "active" or"ur choice"
    'Inactive=0 or "inactive" or "ur choice"
   
'**********************
'check if the parameter passed are valid inputs and if not prompt the user and exit   
    If Trim(functionalitystatus)="" Or Trim(fieldname)="" Then
        Msgbox "Please provide both the parameters for the function enableOrDisable(status,fieldname)",,"Exiting..."
        Exit Function
    End If
'if the status is true then assign 1 to temp or if its false assign 0 else prompt the user to give a valid input and exit
    If functionalitystatus=True Then
   
        temp=ActiveState
    Else
        If functionalitystatus=False Then
   
            temp=InactiveState
        Else
            Msgbox "Invalid type of argument""" & functionalitystatus & """",,"Exiting"
            Exit Function           
        End If
    End If
        'handle errors in case of abrupt termination
   
        'set the current session
    Set session = New NotesSession
        'set the current database
    Set db=session.CurrentDatabase
'        if in case the database is not open prompt the user and exit
    If Not db.IsOpen Then
        Msgbox "The handle for the current database is not set",,"Exiting..."
        Exit Function
    End If
'get the handle of all the selected documents   
    Set dc=db.UnprocessedDocuments
'if in case no documents are selected prompt the user and exit    
    If dc.Count=0 Then
        Msgbox "no documents selected"       
        Exit Function
    End If
    'get the handle of the first document in the collection
    Set doc=dc.GetFirstDocument
    'if the document is nothing then prompt the user and exit
    If doc Is Nothing Then
        Msgbox "doc not set"
        Exit Function
    End If
    'loop through the collection of documents and assign them with the required status information
    While Not(doc Is Nothing)
        Call doc.ReplaceItemValue(fieldname,temp)
        Call doc.Save(True,False)       
        Set doc=dc.GetNextDocument(doc)   
    Wend
   
   
    Exit Function
' prrompt the errors that may result because of abrupt termination   
errHandler:
    Msgbox Error+" on line "+Cstr(Erl)+" in scriptLibrary Function-enableOrDisable"
    Exit Function
   
End Function

Locking Lotus Notes Document Programatically Using Lotusscript - A version independent solution

'define a Script Library with the 'following specifications

'@Name  :  locktest
'@Usage :  Necessary elements to Programatically lock a document irrespective of the version of lotus notes

'(Declarations)
'****************
Dim lockstatus As String
Dim username As NotesName
Dim flag As Boolean


'a function isbeingused()
'**************************
Function Isbeingused(source As NotesUIDocument)
   
    On Error Goto erh
   
    If source Is Nothing Then
        Msgbox "the current document handle is not set  - script library  ""locktest""",,"Exiting"
        Exit Function
    End If
    If source.IsNewDoc Then
        Exit Function
    Else
        'Msgbox  source.FieldGetText("lockingfield")
        If source.EditMode=True Then
            If lockstatus<>"" Then
                Msgbox lockstatus
                Exit Function           
            Else
               
                lockstatus = "The document is in use by "+username.Canonical+Chr(13)+  _
                "So please try again after some time"
            End If
        End If
    End If       
    Exit Function
erh:
    Msgbox "Error in script library ""locktest""" & Chr(13)  _
    & Cstr(Erl)+" "+ Error
    Exit Function
End Function



'a garbageCollector gc()
'*****************************
Function gc()
    lockstatus=""
End Function



'A function isDocumentAlreadyOpen()
'*****************************
Function isDocumentAlreadyOpen(uidoc As NotesUIDocument) As Boolean
    If lockstatus<>"" Then
        Msgbox lockstatus,,"exiting"
       
        isDocumentAlreadyOpen =False
    Else
        isDocumentAlreadyOpen=True
    End If
   
End Function


'*********************************************************
' place the following code in a form (the document source)
'*********************************************************


'(options)
**********
Use "locktest"


'(Queryopen) event
******************
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
    On Error Goto erh
    Call Isbeingused(Source)
    Exit Sub
erh:
    Msgbox "Error in queryopen event on form ""locktest""" & Chr(13)  _
    &  Error +" on line "+Cstr(Erl)
    continue=False
    Exit Sub
   
End Sub

'(Querymodechange) event
'************************
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
    If Not( isDocumentAlreadyOpen(source)) Then
        continue=False
        Exit Sub
    End If
End Sub

'(Queryclose) event
'*********************
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
' nullify the locking field to allow others to access the document once u close it
    Call gc()
End Sub

Sample Lotusscript code to export data from a view to Microsoft Excel document

The following sample code exports all selected documents from a view into an excel file. I am not sure if it works under excel 2003, but i think it's worth a try...

Make sure that you define your own field list before starting the export (*),(**) and (***).
 
'code fragment starts here....
On Error Goto errlbl

Dim count As Double
count = 0
Dim i As Double
i = 1
Dim j As Double
j = 1
Dim lngRow As Double
lngRow = 1
Dim lngCol As Double
lngCol = 1
Dim varApp As Variant

Dim session As New NotesSession
Dim dbCurr As NotesDatabase
Set dbCurr = session.CurrentDatabase

Dim coll As NotesDocumentCollection
Set coll = dbCurr.UnprocessedDocuments

If coll.Count <= 0 Then
Msgbox "No documents found!"
Exit Sub
End If

If coll.Count > 65535 Then
Msgbox ( "Too many documents found!" )
Exit Sub
End If

Dim antwort As Integer
antwort = Msgbox ( "You are going to export " & coll.Count & " documents to excel. Continue?" , 4 , "Start export?" )

If antwort <> 6 Then
Exit Sub
End If

Set varApp = CreateObject("Excel.Application")
If varApp Is Nothing Then
Msgbox "An excel-object could not be created." , 16 , "Error"
Exit Sub
End If

varApp.Workbooks.Add
varApp.ReferenceStyle = 2
Set varSheet = varApp.Workbooks(1).Worksheets(1)
varSheet.Name = "Title of Excel sheet"

'*

Dim liste (0 To 2) As String

liste ( 1 ) = "Fieldname 1"
liste ( 2 ) = "Fieldname 2"

Dim element As Integer

'**

For element = 1 To 2

lngRow = 1
lngCol = i
varSheet.Cells(lngRow,lngCol).Value = liste ( element )

i = i +1

Next

i = 2

Dim feldname As String
Dim feldwert As String
Dim docCurr As NotesDocument
Set docCurr = coll.GetFirstDocument
While Not docCurr Is Nothing

'***

For element = 1 To 2

lngRow = i
lngCol = j

feldname = liste ( element )
feldwert = docCurr.GetItemValue ( feldname ) ( 0 )
varSheet.Cells(lngRow,lngCol).Value = feldwert

j = j +1

Next

count = count + 1
Print count & " documents = "& Cint ( count / coll.Count * 100 ) & " % processed"
Set docCurr = coll.GetNextDocument ( docCurr )

i = i +1
j = 1

Wend

Ende:
varApp.Visible = True
varApp.Rows("1:1").Select
varApp.Selection.Font.Bold = True
varApp.Selection.Font.Underline = True
varApp.Selection.Columns.AutoFit
varApp.Range("A2").Select
varApp.ActiveWindow.FreezePanes = True
varApp.Cells.Select
varApp.Cells.EntireColumn.AutoFit

varApp.Range("A2").Select

Exit Sub

errlbl:

Print ( "Error in ExportData: " & Error & " in line " & Erl & ", fieldname: " & liste ( element ) )

Exit Sub

'Hope this helps!

Tuesday, January 19, 2010

Finding the type on HTML Element which was clicked using Javascript

/*****************************************************************
@Purpose    :    To find the Type of HTML Element from which the a event is fired
@Created:    19-Jan-2009
@Author:    Karthikeyan A
@Name:    myClickListener
@Param:    e - refers to event object
@Return:    A- for anchor tags
                 INPUT- for <input ..../> tags
                 TEXTAREA- for <TextArea.../>tags etc...
*****************************************************************/
function myClickListener(e)    {
    //variable to store the name of the element on which user clicks
    var eventIsFiredFromElement;
    if(document.all)    {        // IE
        eventIsFiredFromElement = e.srcElement;
    }    else    {        // Firefox
        eventIsFiredFromElement = e.target;
    }

    //alert("Event is fired from element : " + eventIsFiredFromElement.tagName);
    return eventIsFiredFromElement.tagName;
}

Creating a location document in Lotus Notes Client

Following is a procedure to create a simple location document in your notes client

1. Open up your Notes Client and open the local "Names.nsf" database



2.Click on "Advanced" in the left navigation menu



3. Click on Locations ->New ->Location as



4. Now a new location document will be open for editing
In the basics tab, mention your location name (as highlighted in the image)
In the Advanced tab->click the Basics tab-> and key in the path of the id file (as highlighted in the image) that you want to switch to when you move to that location


5.Now save and close the location document. In the bottom right corner of your screen click on your current location name to view a list of exisiting locations and you will be able to view the newly created location as highlighted in the following image


Hope this helps

Monday, January 18, 2010

How do you start or stop a windows service

Click Start -> Run
Type in "services.msc"
This will bring up the "Services" window

This will contain a list of all the services present in your machine.
Just right click on it to say start or stop the service as illustrated in the following image

Handling Errors that popup, once windows starts

I have faced these sort of issue quite often. When ever my windows boots up, I will start getting a few error message pop ups stating a few registry entries or corrupt or windows failed to load a task etc....

I tried running registry fix ups, anti virus scans, spyware fixes etc and every thing failed.

It was then that I found out the reason behind the errors were cause of a software that I have installed in my machine.

In order to sort it out, I followed the following procedure.

Click Start-> Run
Type msconfig
The "System Configuration Utility" window pops up,
Go to the "Startup" tab
Click on Disable All
Click on Apply, Close and Restart in the new window that pops up.


The next time when my machine booted up, I did not recieve any errors.

Thus I found the source, so to narrow down on to the specific application, enable or check a few items in the list ,Apply and re-boot your machine untill the problem reoccurs. Thus when the problem reoccurs at a specific point, go a head write down the name of the item that resulted in the error ,

google it and find the nature of the application if you dont know about it, try fixing the application or remove or reinstall the same to fix the issue permanently

The same sort of problem is common with services running in the windows too.
In this case you may have to select the "Services" tab,
Click on "Hide All Microsoft Services" ,
Click "Disable All"
Restart your machine and see if the issue reoccurs .
If the issue does not occur then the problem is with one of the services listed in the services tab.
So use the same trial and error method that we used for the previous case, narrow down to the service and fix the issue

Creating Speedometer in Microsoft Excel

Microsoft Excel has various chart features that can be used to display various data in graphical format. How ever, we do not some thing straight like the Speedometer. And this post would help you do it.

To add more sense to what I am speaking about, let me show the end result.Take a close look at the following figure.Yes this is what I am proposing to achieve on the Excel sheet.


Procedure:

1. Create a new Excel sheet with the data as shown in the following figure. Make sure that you dont change the formulas in the cells, un less you are certain that you know what you are doing and can relate to the changes at any point of time during the creation of this Speedometer


2.Highlight the cells B2 to B5 and click on View->Other Charts->Doughnet as shown below

This will give you a chart like the one in the following.








Right Click on the doughnut chart thus created, select "Format Data Series". In the Series Options, mention the angle of first slice as 90 and click close. Now the chart will look like the one in the following



Select the blue colored section, right click on the same , in the Fill tab specify "No Fill" and in the Border Color tab, specify "No line". You should see a graph as displayed below,




Right Click on the Doughnet chat,
click on "Select Data",
Click on "Add" to add a series,
Now in the Series Name field, give the value "Series 2",
click on the Series Value field and select cells, c2:c13 in the Excel sheet and say ok.

Now you will see a graph as displayed below.




Now goto the following url, download and install the tool,
http://j-walk.com/ss/excel/files/charttools.htm
This will work only in Windows


Use the add-in to format Series 2 to display data labels using the range D2:D14. Keep Series 2 highlighted, then double-click to bring up the Format Data Series dialog. Go to the Patterns tab, and select None for both the Border and Area. Your chart should look like that shown in the following figure

Now add a new series named "Series 3" with values "E2:E5" and say ok.
Now your graph will look like the following


image4

Now Right click on Series 3 and and
click "Change Series Chart Type..."
Click Pie chart and click ok
Now select the pie chart, right click on it,
click "Format data series"
In Series Options mention "Angle of first Slice" as 90 degrees,
in the Fill tab specify "No Fill" and in the Border Color tab, specify "No line".
 Select the smaller slice of the pie chart and provide a fill color for it alone

Thus you will see the a graph similar to the following,


Now in the Excel sheet change the values of the cell F3 to some thing in between  0 and 100 and you will be able to see the graph changing

Also click on the unwanted labels and delete them to give a complete decent look. I have changed the values in the cell F3 to 40 and deleted a few labels somy graph looks like this,
 

!! Hope this helps you...  !!

Thursday, January 7, 2010

Windows Service for sharing folders

When you attempt to share a particular folder in WindowsXP and if it complains that, the Windows service for sharing folders is not started, then following procedure shall help you in resolving the issue

1. Click Start -> Run
2. Type Services.msc in it
3. The Services Window will open up. Now Scroll down to the service named "Server". Right click on it and click Start
4.It may take a while to start. Now close the Services window and share the folder that you want to share.

This will fix the issue.

Again if you share a folder named "TestShare" and try to access it from a different machine using the IP address of your machine, say something like //ipaddress, it may fail.

Try accessing using "//ipaddress/TestShare"

Issues In Previewing A Lotus Notes Application In Local On Web

Initially when I started to learn about web development in lotus notes, I started with the usual way by which I learned the application development in Notes Client.

So I created a database, created a form in it, Typed in "Hello Lotus Domino Web World" and previewed it on the browser.

That was how it all started for me.... A series of problems

1. The very first error that I received is
-----------------
Error 404
HTTP Web Server: Lotus Notes Exception - File does not exist
-----------------

The issue was that, I previewed it first on Fire Fox in Windows XP platform

Inorder to preview a lotus notes database on web, you ought to have nhttp task running on your machine. By default when a server starts it will automaticaly get loaded and if in case its not running u can pass a console command saying "load http" and the task will be loaded if its not running currently.

Where as in case of a database present on your local machine you have to initiate it manually.

And the simplest and only way i know to do that is to preview a form or a page present in a database in local on IE first.This will start the nhttp task on your local machine.

Then you can preview any thing on Fire Fox or other browsers directly.

2. Still my application failed to open as a result of some authentication errors.
Server Authentication happens as you load a page from the server. It will ask you for your Username and Password that it can recognize. But in case of local databases, there is no such phenomenon.

So the solution to fix this issue is Add a user named as Anonymous and give it at least Editor access.

This will help you in skipping the authentication part, but with a serious Security risk. Any one and every one will be able to access your database on the web if the use your machine.So I personally feel this is ok for learning purposes only

3. After a while, I happened to login into Skype for some official reason and left it as such. And then I switched back to my learning mode and started my work.
This time again, I had the very first issue, mentioned in this topic

Now the issue is the nhttp task on local uses your local port 80( may be 8080 ). Softwares like Skype also uses the same port. So your nhttp gets blocked.

So the solution is to exit any thing that uses this port to let your local databases be previewed on the web.
You may have to speak with your system administrators to sort out what is running on that specific port

Hope this helps :)

Bulding Strings from Char and Bytes

Following is the definition of a over loaded function named buildString that shall help you to build strings from characters, character arrays, bytes and byte arrays

public String buildString(char chars[]){
String returnString=null;
returnString=new String(chars);
return returnString;
}

public String buildString(char chars[],int startIndex, int numOfChars){
String returnString=null;
returnString=new String(chars,startIndex,numOfChars);
return returnString;
}

public String buildString(byte bytes[]){
String returnString=null;
returnString=new String(bytes);
return returnString;
}

public String buildString(byte bytes[],int startIndex,int numOfChars){
String returnString=null;
returnString=new String(bytes,startIndex,numOfChars);
return returnString;
}

Monday, January 4, 2010

How do you change the Static IP of your machine running on Windows XP Professional, Service pack 2

I had a VM installed in my machine with which I play around to install dummy servers and other necessary stuffs to test my applications' credibility and robustness.

It was one fine day on which my superior directed me to the marketing team to help them install a VM and put all our products together so that they can use it to demo our clients.

Accordingly I got this idea of copying my VM to their machines as I already had every thing in sort of demo-able state in it. Consequently I did the same and was happy after receiving a big thanks from the marketing team.

But Knock! Knock!... A problem hit me.

The next time when I started my VM .. i got an error which said sort of following:
Duplicate IP Address Exists in the network

So eventually i asked my friend google to help me with this issue and he suggested me to change static IP in either of the machines.

The following is what I followed
1. open control panel
2. open network connections
3. Right-click on the network which helps you go online
4. Now a list of check boxes would be visible and among them will be the following option "TCP/IP". Click on it and then click properties
5. Now you will be able to see a provision which will allow you to mention ip address, sub net mask, default gate way etc...
6. Change the IP and say ok
7. Say apply on the main window

To ensure that your new ip has gotten into effect, open command prompt and type ipconfig

This should display the newly changed ip address for your machine.

session.CurrentUserName in agentURL?OpenAgent

Have you ever tried to print the current user namen the browser by using a lotus script agent with a code say

   print session.currentusername

triggered by a javascript command say,

  location.href="http://servername/databasepath/agentname?openAgent"

What do you think will be printed on the browser?

Canonical form of the current user's name..!!!

No you will get the canonical name of the person or the server who has signed the agent

Yes thats true. And it did trouble me in my project. So How do you overcome it.

Scenario 1: put a computed text on the page or the form being displayed on the browser with the formula @username and ensure that it goes into a html field with some ID. You can always get the current user name using that htm field and pass it along with the agent url as a query string as mentioned below

  location.href="http://servername/databasepath/agentname?openAgent&userName="+document.getElementById('userNameField').value

Then in the lotus script agent you can obtain the query string and hence the user name

Scenario2 (The one I encountered):
The page being displayed on the browser is built by an agent you are not allowed to modify the same except for one single place and that is where I have to trigger my agent.

This issue was resolved through the following means.

Create a Page with the name userInfo.xml with content type set to other: text/xml.

<userInfo>
 <userName>
  <computed-text> with formula @username
 </userName>
</userInfo>

Now trigger a ajax request to this page,
obtain the response,
parse the xml and get the user name.

Now as mentioned in Scenario 1 pass this in the query string and do as necessary

Hope this is help ful