Notes of my Lotus Notes Headline Animator

Search My Blog

Friday, October 14, 2011

Refresh a form keeping its field values


To refresh a form keeping its field values as is:

http://authorsloft.com/SupportRef.nsf/e6b464faa52c14d1852567d90082c48f/1c05fb75304ce7a685256b710005fb38!OpenDocument

Copied the content from the above link:
Domino form / document refresh using JavaScript:

Better Option (Domino6 + ):
if(ValidationFunc()==true) {
return _doClick('$Refresh', this, null);
}

A longer version to specify a frame and what field to base refresh on:
return _doClick('$Refresh', this, '_self', '#_RefreshKW_' + 'somefieldname' );

To refresh the document

To refresh the entire document in client : @Command([ViewRefreshFields)
And to refresh entire document in web : _doClick('$Refresh', this, '_self', '#_RefreshKW_')

To run an agent from lotus notes webpage

To run a Lotus-script agent from a lotus notes webpage:

1) Write @Command([ToolsRunMacro]; "(MyWebAgent)") in the button's programmer pane Client > Formula and it will work when you click the button. No need to do Pass-thru HTML for this button.

If for some reason you are still not able to achieve your result, you can use an indirect approach, i.e.

2) In your button where you have written the code for running the agent, in it's Properties > HTML tab, give a name  and id to it. It's better if we keep the value for Name and ID same.

Then create another Button or link and in that write in the programmer pane Web > Javascript, document.forms(0).<the button's ID value>.click()

i.e. document.forms(0).btnCheckDuplicate.click()

Thus, the first button will be triggered with the click() event and your agent will run.

Proper way to logout a website...

Proper way to logout is a website in lotus notes:

After you use the default logout code you must redirect the page to another page.
This way if a PC is being used by multiple users it will not open the same session.
Once you redirect to another page, it kills the session completely post logout.

Syntax:
top.location = self.location.href.substring(0,self.location.href.indexOf('.nsf') +4) + "/<framesetname>?logout&redirectTo=http://"+window.document.forms[0].Server_Name.value+"/"+window.document.forms[0].DBNameTX.value+"/";

This is a response that I posted in IBM developers forum.
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/7ba21b9304eaa6d6852570e500215ebf?OpenDocument

Monday, August 22, 2011

$$Fields and Reserved Notes Field Names Glossary



I got this content long back from some website.. can't remember.
I found it very useful. So, here it is for your use..


$$Fields and Reserved Notes Field Names Glossary
Anonymous on 08/26/1999 at 07:51 PM

Category: Notes Developer Tips
Forms/Subforms, Formulas
$$ Fields

$$HTMLhead
If you don't use the "For Web Access: Treat document contents as HTML" form property, adding a $$HTMLHead field to a form allows you to pass HTML information, such as Meta tags and JavaScript, to the Head tag for a document. The field can be any data type, but a hidden computed-for-display text field is the best choice.
(source: Notes Help 4.6)

$$QueryOpenAgent (4.6) or the form event WebQueryOpen (4.6)
The Notes Help 4.6 says about WebQueryOpen: A WebQueryOpen event runs the agent before Domino converts a document to HTML and sends it to the browser. Domino ignores any output produced by the agent in this context.
Create a shared agent that runs manually. Then write a formula that uses @Command({ToolsRunMacro}) to run the agent and attach it to the WebQueryOpen form events.
This simulates the LotusScript QueryOpen form event that isn't supported on the Web.
The $$QueryOpenAgent field works in the same way. Works also in 4.6.

Thursday, August 4, 2011

Validating a rich text field

Validating a rich text field:

http://www.ibm.com/developerworks/lotus/library/rich-text-field-notes/

I have copy pasted the three methods from the above link for my reference.

Method 1

In the first method, if the field contains any input (even only a single space character), then it can pass the validation. This validation uses the Querysave event of the form that contains the field. The following LotusScript sample code performs this validation:


Sub Querysave(Source As Notesuidocument, Continue As Variant)
            If ( Source.FieldGetText( "rtfield" ) = "" ) Then
                 Messagebox( "Please enter some text." )
                 Call Source.GotoField( "rtfield" )
                 Continue = False
         End If
End Sub


The code checks for any character in the field rtfield. If the field contains input (even if it consists solely of one or more space characters), then validation succeeds. If the field is empty, then the code returns an error message, and doesn’t save the document (by setting Continue to False).

Method 2

In the second method, the rich text field must contain at least one non-space character (in other words, an input consisting entirely of one or more spaces is not allowed). This check also uses the Querysave event of the form:


Sub Querysave(Source As Notesuidocument, Continue As Variant)
        
         Dim rtitem As NotesRichTextItem
         Set doc = Source.Document
         Set rtitem = doc.GetFirstItem( "rtfield" )
         Dim text As String
        
         text$ = Source.FieldGetText("rtfield")
         trimmed$ = Trim(text)
           
            if ( trimmed$ = "") Then
                 Msgbox "Please enter some text."
                 Continue = False
                 source.GotoField("rtfield")
                 source.Refresh(True)
         Else
                 Continue = True
                
         End If
End Sub


Method 3

Our third method validates a rich text field in which an input consisting solely of an attachment, embedded object, or link is allowed, even if it includes no accompanying text. Once again, we use the Querysave event of the form containing the field:



Sub Querysave(Source As Notesuidocument, Continue As Variant)
        
         Dim rtitem As NotesRichTextItem
         Set doc = Source.Document
         Set rtitem = doc.GetFirstItem( "rtfield" )
         Dim text As String
        
         text$ = Source.FieldGetText("rtfield")
         trimmed$ = Trim(text)
        
         If(doc.Hasembedded)  Then
                 Continue = True
                                  
         Elseif ( trimmed$ = "") Then
                 Msgbox "Please enter some text."
                 Continue = False
                 source.GotoField("rtfield")
                 source.Refresh(True)
         Else
                 Continue = True
        
            End If
End Sub


This code will work if there is an attachment anywhere in the document, even if it's not in the field that is being validated.