Pages

Showing posts with label Bugs. Show all posts
Showing posts with label Bugs. Show all posts

Monday, September 30, 2013

Crash Lotus Notes - Oops I did it again

In an attempt to write a fairly complex workflow application, which I originally thought was a so simple I did this. I was dumb enough to have given way for the "out of touch since last two years" concept to ridicule me like this.

I knew that theoretically, I can write custom lotus script classes which can extend native lotus script classes and I can possibly extend/create events like querySave, queryClose etc using some thing like the following

On Event Querysave From customUidoc Call customQuerysave

So I went a head and tried it to discover that I crashed my client. I am great full that I dont posses the talent to corrupt database designs at will. Honestly.

Sometimes the thought scares the hell out of me. I just tried to do the above mentioned stuff. Just tried. And following happened. Note- I am not sure if this would happen always or not, but I think its worth mentioning this. I already had a custom class on the script library where I was trying to build my new custom class and extend NotesUIDocument.


I am on the way persuading about what really guided me to collapse my Lotus Client.  Hope I would find a solution to the same :@  !!!!

Thursday, September 12, 2013

Crash Lotus Notes - Oops I did it again

It has been quite a while since work was such fun. :) I had missed to log a lot of ways by which I ended up crashing lotus notes last year as they seemed obvious and straight forward. This time I think I discovered a new way to do it :P

It is by make a view feel miserable when a document is opened from it. Yep its the queryOpenDocument event of the view.

I just put the following code into it

Sub Queryopendocument(Source As Notesuiview, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim currDB As NotesDatabase
Dim selectedDoc As NotesDocument
Dim caret As String
caret=source.CaretNoteID
Set currDB=session.CurrentDatabase
Set selectedDoc=currDB.GetDocumentByID(caret)
Call workspace.SetTargetFrame("*********")  '- dont get any ideas. Just put a valid frame name 

Call workspace.EditDocument(False,selectedDoc)
continue=False
End Sub

This happens even if I comment "continue=False" 

I really dont know about how to fix it rolf :)

Tuesday, January 3, 2012

Bugs: "Element or Navigator is invalid" error when using NotesRichTextNavigator


-->
Let me dive straight into the point.  Assume that I have few document say five documents with a rich text item in each one of it and all of them are created using same form. So don’t bother about minor variations like missing document items etc… To make things simple let me say that these five documents are design equivalent.

Now let me say that I don’t put any values inside the richtext field in 3 document alone. So on the contrary I have values on all the 4 remaining documents.


Now assume that I have the following sort of code in an agent


On Error Goto errhandler
                …….’some code               
                Set dc=db.UnprocessedDocuments
                Set doc=dc.GetFirstDocument
                Set richStyle = session.CreateRichTextStyle
                richStyle.PassThruHTML = true
                                
                While Not doc Is Nothing
                                itr=itr+1
                               
                                Set richText=doc.GetFirstItem("myRtField")
                                Set rtnav=richText.CreateNavigator
                                                               
                                Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTRUN)
                                Call richText.BeginInsert(rtNav)                   ---------------------à>> when itr=3 this line will error out with error number 4506
                                Call richText.AppendStyle(richStyle)
                                'Call rtnav.GetLastElement(RTELEM_TYPE_TEXTRUN )
                                Call richText.EndInsert
                                Call richText.Update
                                'Call doc.Save(True, False)
                                Set richText=Nothing
                                Set rtnav=Nothing
                                Set doc=dc.GetNextDocument(doc)
                                Print Cstr(itr) & " doc processed"
                Wend
                Exit Sub
errHandler:
                If Err=4506 Then Goto skiploop
                Print Error & " *** occured on line *** " & Cstr(Erl) &"*** with error number *** " & Cstr(Err)
                Exit Sub




As you may understand the since the rich text field in the third document is empty an error with number 4506 will occur.


You can say that one can handle this scenario by using some thing like “IF rtnav Is Nothing Then goto SkipLoop” etc… but it did not work so I managed to loop the control back in my error handler section.


And guess what, the object rtnav becomes unusable. I simply does not set any right values the next time the loop executes and does not accept any values. And so the following error occurs




And alas… the code breaks. Complier does not even make it to the error handler.


So sad L


I think I know a work around for that. So stay tuned

Saturday, October 15, 2011

Bugs: Ajax Caching issue in IE

Hats of to IE. It tests my mettle. Not a day goes by with out finding issues with IE one way or the other when I attempt to get some thing work the way I expect them to.
The good part is it helps me learn a lot from technology point of view as it is so different from other browsers and even simple things require a lot of work in IE.

Once an ajax request is created from the IE browser, it caches the same if it is a get request and this is absolutely absurd. I try getting a value through an Ajax request that varies frequently and because of this cache, I dont get the most recently updated value.

I have to restart the browser to get the recent value.

But with Post request, thank god, they are out of IE's caching issues. My saviour of the day is- AJAX POST REQUEST. This forces a fresh new request be triggered every time and the parameter that I provide are safer too.

Wednesday, March 23, 2011

Crash a Domino Server - an other SSJS did it

In addtion to what I have found previously - http://ozinisle.blogspot.com/2011/03/crash-domino-server-oops-ssjs-did-it.html, I happened to stumble upon an other code fragment that did it. I mean crashing my domino server.

This time its a more serious one to be aware of. Because the following line of code works perfectly until it breaks. So be care full.

viewHandle.getColumnValues(colNumber)

where, viewHandle is a NotesView object.

Hope this helps :)

Wednesday, March 16, 2011

Crash a Domino Server - oops SSJS did it

In an attempt to simulate @DbColumn using SSJS, i used a few lines of code which included the following,

doc.getColumnValues();


To my astonishment, I found that my domino server had crashed. Yes the server it self had crashed every time it read this code fragment.

I have coded a few lines in the past that crashed Lotus notes client/designer, but never had the opportunity to crash a server. And now it took me XPages to do it :)

Looking for a work around :(

Wednesday, February 23, 2011

Issue : dojo.xhrGet fails in Safari

It was one trouble some situation when I found that my dojo.xhrGet failed in Safari. I felt like I was hanging in a cliff 500 feet deep. with no way back :( untill I stumbled upon the following forum discussion,

http://www.devcomments.com/cross-site-ajax-using-dojo-xhrGet-doesn-t-work-as-expected-but-at200443.htm

An amazing one. The first few posts are not visible for some reason but the vital ones that resolved the issue where visible.

The abstract of what I understood from issue that I faced and the discussion in this forum are as follows,

1. When using dojo.xhrGet, a preflight request get triggered from safari. And that means an Ajax request is triggered to the server before server authentication could occur. And this posed a severe security threat as Anonymous access to my Lotus Notes Database has to be enabled for dojo.xhrGet to work on Safari.

2. The trick was to use dojo.xhr instead of dojo.xhrGet . The documentation on  dojo.xhr can be found in the following location -http://dojotoolkit.org/api/dojo.xhr

3. The context that we need to understand here is that dojo.xhrGet({arguments}) is same as dojo.xhr("GET",{arguments}). And this is one of the vital points that resolved the issue

In addition to the above, to tackle the preflight request issue, it is better, if one can check on the play around with the "sync" flag. It is not that playing around with this will definitely resolve the issue but there are paucity of chances that it might help.

Hope this helps :)

Monday, September 20, 2010

Getting User's Name on the XPage

The content that I am trying to describe on this particular post is fairly simple. Many of you guys out there would have faced it and solved it. But still I would like to share this cos, really XPages are stupid at times.

I had the formula session.getCommonUserName() on a lable which worked for me through out the period I was developing my last application. When I moved the same to a test server to test the same, to my astonishment I found that the label with the above mentioned code displaying my test server's name.

I opened up the XPage in designer, saved it manually,
Signed the database using server id,
compacted the database ,
Restarted my test server etc etc...

All of the above steps failed and it still kept displaying my server name

Later I changed the code to @Name("[CN]",@UserName()), the formula eqivalent in server script.
OOPS that failed tooo...

And after a few brief moments of frustrations, I got the following idea,
@Name("[CN]",session.getEffectiveUserName())

And that eventually saved me.

Feels strange aaha...

Hope this helps :)

Roles in XPages

I had a hard time working with user roles in XPages.

  I used to the following procedure which is a server script equivalent of the lotus script equivalent of the @UserRoles which wont work on server side javascript :) (confusing aaha...)

var acl:NotesACL= database.getACL();
var entry:NotesACLEntry = acl.getEntry(@Name("[CN]",@UserName()))
if (entry==null)    {
    entry = acl.getEntry(session.getUserName())
}
 
if (entry==null)    {
    return "";
}

entry.getRoles();


It did work to some extent. But I really had a very tough time with this. It seemed to work fine for a while but to my astonishment it started showing only my server's role enabled on the database . It was very irritating and I felt ridiculous about it.

Later I explored the web to arrive at the fairly simple decent solution as follows,

context.getUser().getRoles();

Yes the above mentioned line did the job for me. Hope this helps some one :)

Thursday, June 3, 2010

#9: Issue in XPage: Xpage refresh results in creation of duplicate documents

I am currently facing an issue in Xpages which is haunting me....

Initially I had issues with Required fields getting validated in every server refresh. I fortunately stumbled upon Tommy Valand's blog and found beautiful solutions to many issues. When I used the code and fixed the same.. this monster arrived at my door step...

A brief description would be,

1.Open an Xpage which is bound to some data source and has a submit button which saves the underlying document.


2. Save the XPage by clicking the submit button and cross check with the view that displays the underlying document in notes

3.Now press F5 on key board. You will get a prompt saying the following message,

The page you are trying to view contains POSTDATA. If you resebd the data,
any action the form carried out(such as a search or online purchase) will be
repeated. To resend the data, click OK. Otherwise, click Cancel.


4.Clicking Ok on this prompt will create a duplicate document

This is one issue that is haunting me in my current project

Thursday, May 20, 2010

#8: Issue in XPage: Inconsistency across browser and client when attempting a new window popup in XPage

My goal was to dump a few html content into a new window and print the same.
I tried the following function on a button in an XPage

The following code goes in the onclick event of the button ,

writeConsole( 'Hello from JavaScript!' );
function writeConsole(content) {
  top.consoleRef=window.open( '' , 'myconsole' ,
  'width=350,height=250'
    + ',menubar=0'
    + ',toolbar=1'
    + ',status=0'
    + ',scrollbars=1'
    + ',resizable=1' )
 top.consoleRef.document.writeln(
  '<html><head><title>Console</title></head>'
    + '<body bgcolor=white onLoad="self.focus();self.print();">'
    +content
   + '</body></html>'
  )
 top.consoleRef.document.close()
}


When I preview the Xpage on the browser and click the button containing the posted code, I get to see the expected functionality. Where as when I see the same on the NotesClient 8.5.1, I see nothing happening -- Absolutely nothing.

I remember IBM telling people that XPages on 8.5.1 will work exactly in the same way, both on the Notes Client and on the browser...

Am I missing some thing.... If not this issue is definitely a bug in 8.5.1 XPages

Friday, April 30, 2010

Issues with using pipe ( | ) symbol in Evaluate method in lotusscript

When attempting to use @DBLookup in Evaluate using lotusscript the following attempt succeeded


Evaluate({ @DbLookup("";"";"vwDB";"userName"; 2 ) })

But, replacing the curly braces with the pipe symbol failed,
I mean the following,
Evaluate(| @DbLookup("";"";"vwDB";"userName"; 2 ) |)

I even tried introducing the document parameter,in the following fashion,
Evaluate(| @DbLookup("";"";"vwDB";"userName"; 2 ) |,contextDoc)

I tried this in 8.5.1 and I believe it must be the same with all the other versions as well.

Friday, March 5, 2010

My Unanswered questions in XPages

 Assume that you have a Edit box control named "MyXSPField" on a XPage.
Now If I want to retrieve the value of the same on a button click, I can do it in the following ways,
 i,
   var fieldValue=document.getElementById("#{id:MyXSPField}").value

 ii,
   var computedId= "#{id:MyXSPField}";
   var fieldValue=document.getElementById(computedId).value

But when I attempt to split the parameter as follows, no matter what ever way that I try, which makes sense to me, the attempt fails to give me the field value
 i,
   var editControlName="MyXSPField";
   var computedId= "#{id:"+editControlName+"}";
   var fieldValue=document.getElementById(computedId).value


 ii,
   var editControlName="MyXSPField";
   var fieldValue=document.getElementById("# 
   {id:"+editControlName+"}").value

 iii,
   var editControlName="MyXSPField";
   eval ('var fieldValue=document.getElementById("#
   {id:"+editControlName+"}").value');

 iv,
   var editControlName="MyXSPField";
   eval ('var fieldValue=document.getElementById("# 
   {id:"'+editControlName+'"}").value');

 v,
   I have tried replacing # by $ in all of the above mentioned attempts

Yes.. All of these attempts fail. I understand that I am breaking the EL (expression language) and that might be the issue....

But is there a way to instruct the XPage compiler to complile the dynamically created EL, 'cos this is a real worrying issue







Friday, February 12, 2010

#6 : Bugs I Found : Javascript comments get compiled in XPages

I had the following code in a button on the XPage.
try {
var id="#{javascript: getComponent(prototype.name).getId()}"; //---this line produces error
    alert(id);
} catch (error)    {
    alert(error.message);
}
When I attempted to open the XPage , I got the following error,
 /**********************************************************/
Unexpected runtime error
The runtime has encountered an unexpected error.
500 Exception
Error while executing JavaScript action expression
Script interpreter error, line=1, col=30: 'getComponent()' is null

►  Stack Trace

 /**********************************************************/

Hence I attempted something different after commenting the same line as follows
try {
//var id="#{javascript: getComponent(prototype.name).getId()}";
var id="#{javascript: getComponentInstanceId()}";
    alert(id);
} catch (error)    {
    alert(error.message);
}

and previewed the same on the notes client...
Oops.... got the same error ....

After tinkering a bit, I removed the comment and placed a code as is mentioned below,
try {
var id="#{javascript: getComponentInstanceId()}";
    alert(id);
} catch (error)    {
    alert(error.message);
}


and that worked.....

A possible bug with javascript comments in XPages

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)


:)

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