Home > Domino Tips > Developer > LotusScript > 10 everyday LotusScript tips
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

10 everyday LotusScript tips


Bill Buchan
03.27.2007
Rating: -3.96- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


  1. Use error trapping
  2. Use defensive coding
  3. Protect your code
  4. Use NotesDateTime instead of strings
  5. Use DXL as Transport
  6. Use wizard interface in your Notes client
  7. Consuming Web services
  8. Use classes
  9. Use the Evaluate command
  10. Use "trusted servers"

  Everyday LotusScript Tip #1. Use error trapping 

Error trapping tests a particular condition when running a program. If the program runs into an error, it will then execute a corresponding routine to fix the error. This should always be done. Error handling is not a joke -- it should always be handled in a serious manner and should always be mandatory.

There are two ways to go about this:

  • Use a single error handler at the top of your LotusScript code. It is simple to implement, but at times difficult to keep in context.

  • Implement your error handler at the function level. It's a little bit more work, but it's also much more granular.

  Everyday LotusScript Tip #2. Use defensive coding 

While it may seem a bit paranoid, you should practice using defensive LotusScript coding -- it will save you time in the long run. Always assume the worst and check all inputs on every function. It doesn't usually affect performance, but it is a good failsafe.

Here is a good example of defensive LotusScript coding in a typical function.

  Everyday LotusScript Tip #3. Protect your code 

When creating commercial applications, it's a very good idea to hide your code. But, you may be asking how. There are actually two ways you can go about it:

  • Create a template and click on "hide design." This is easy to do, but it may end up allowing form customization.

  • You could also remove your LotusScript source code from your script libraries. Use the NotesNoteCollection command to find your script design document. Then replace the "$ScriptLib" with a String -- "Hello." This is not the easiest way to go about this process, but your other design elements can be modified as well. (Do not do this on your development copy!)

...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
LotusScript filters and attaches files to a Notes form

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


  Everyday LotusScript Tip #4. Use NotesDateTime instead of strings 

You should never store date/time values as strings. It is always good practice to use NotesDateTime structures instead and save them.

You might say, sure, but why? Well, you never know how the client will interpret dates. Is it dd/mm/yyyy or mm/dd/yyyy? It also means that views will be able to sort on dates.

Trust me, this is a good tip to practice. This issue comes up more often than you might think.

  Everyday LotusScript Tip #5. Use DXL as Transport 

A good reason to consider using DXL as Transport stems from a situation where a customer wants to easily send back "log" documents. When this happens, you can use a LotusScript agent to:

  • Pick up all selected documents.

  • Create a memo with a rich-text field.

  • Use DXL to store the documents in the rich-text field.

At the receiving end, this will:

  • Unpack the mail message to a DXL stream.

  • Construct new documents to store the data.

This way, you are transferring data without replication. Below is a sample code of this being implemented.

  Everyday LotusScript Tip #6. Use a wizard interface in your Notes client 

When using a wizard interface with your Lotus Notes client, there are a few steps you should follow:

  • Create a form with a tabbed table.

  • Set the tabs to "1," "2," "3," etc.

  • Select "Switch Rows Programmatically."

  • Set the "name" field to the name of the table; for example: "RequestTable."

  • Create a variable on the form with $Name; for example: "$RequestTable."

  • Have your "forward" and "back" buttons increment/decrement the variable.

  Everyday LotusScript Tip #7. Consuming Web services 

There are two different ways you can go about consuming Web services. The first is quick and to accomplish it, you should follow these steps:

  • Install Microsoft SOAP on client machines.

  • Write LotusScript to create a Microsoft SOAP object. This is a good option because it is quick and handy when it comes to testing. Unfortunately, it is platform-specific, requires dynamic link libraries on clients, and there is no timeout.

Below is some code that illustrates how to create the Microsoft SOAP object.

The other approach is a little different. It's big and robust and uses Stubby. Just point it at a Web service and it produces the code for you.

Some good points about it are that it is multi-platform, scalable and there are no dynamic link libraries. However, it does require you to use more than four lines of code.

  Everyday LotusScript Tip #8. Use classes 

When developing with LotusScript, it is always a good idea to use classes. Here are some reasons why:

  • Classes help to bundle data and code in one place.

  • They decompose problems into "objects."

  • They help to write smaller, more focused code.

  • They help define and implement the internal data model.

  • They aid reusability.

Classes have a good design methodology, which leads to Java. But everyone is not used to them and it may take time to sink in. Below you will see some code that implements classes.

  Everyday LotusScript Tip #9. Use the Evaluate command 

The Evaluate command allows you to run @Functions within LotusScript. It is sometimes quicker and easier, as it allows you to use your favorite function in certain situations.

An example of it might be:

Don't overuse it though. Loads of LotusScript functions mimic @functions.

  Everyday LotusScript Tip #10. Use "trusted servers" 

It is good practice to use trusted servers because scheduled agents cannot normally open databases on other servers.

The "trusted servers" field in a Lotus Domino R6 server document's security section allows servers to trust other servers. By doing this, it allows you to centralize "collection" agents. You also simplify your architecture and limit the number of agents you use. However, it does rely on a fast, reliable network infrastructure.

As a final note, make sure to never trust servers in another domain.

[IMAGE]
[IMAGE]TUTORIAL: 30 LOTUSSCRIPT TIPS
[IMAGE]
[IMAGE] Home:
Introduction
[IMAGE] Part 1: 10 fundamental LotusScript tips
[IMAGE] Part 2: 10 everyday LotusScript tips
[IMAGE] Part 3: 10 advanced LotusScript tips
[IMAGE] Part 4: More LotusScript learning resources

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts