Showing posts with label Useful Code. Show all posts
Showing posts with label Useful Code. Show all posts

Monday, 4 April 2011

Button to open db on a particular server

We have many servers in our environment and we try to make sure users use their local server for their applications.  Below is a simple button to force a user to open an application on a particular server, which will place this replica on top of their replica stack.

Wednesday, 23 March 2011

Import Excel file

Here is some sample code to import a Microsoft Excel file, rather than a CSV file.  I was looking for some sample code to help release the task on the server.

Thursday, 10 March 2011

Months as text

Below is some useful code I have used many times.  This allows you to take a date field and display the month of the field.  I have used this in categorised columns many times for many years.  You have to make sure that if the month number is less than 10 that you prepend a "0", otherwise the month of 11 would become "JanuaryJanuary". 

Get week commencing date

If you want a week commencing date of Monday.... 

Unhide Design

I have a number of templates where a rogue developer has locked the design and has lost the templates (or won't share them). 

There is a solution to unhide the design.

1. Make a local copy of the database
2. Ensure you have manager or designer rights.
3. Open up the .nsf file in a hexadecimal editor.
4. Change address 000000BC from the hexadecimal code 20 to 00.
5. Save the .nsf file.
 

This does not seem to work with 8.5.1

Refresh db from the console

This is a command I run very often.  Below is an example to refresh a single database in the EU\CSSD\eSupport directory. 

Server Commands

Thank you Paul Dotter.... 

Sign db

Here is the code to sign a database with LS.

@left in LotusScript

Here is the code

@adjust in LotusScript

Here is the code

@right in LotusScript

Here is the code...

@dblookup in LotusScript

Here is the code...

@DBColumn in LotusScript

Function DBColumn (strClass As String, strNoCache As String, strServer As String, strDatabase As String, strView As String, strKey As String) As Variant Dim strFormula As String,quotes As String quotes = Chr(34) strFormula = “@DbColumn(” & quotes & strClass & quotes & “:” & quotes & strNoCache & quotes & “;” & quotes & strServer & quotes & “:” & quotes & strDatabase & quotes & “;” & quotes & strView & quotes & “;” & strKey & “)” DbColumn = Evaluate( strFormula ) End Function

Monday, 7 March 2011

Copy fields from doc to uidoc

I needed to be able to copy fields from a saved document to the document on screen.  This was in our HR system, where we set objectives and KPI's for bonuses.

I made life easy for myself by naming all of the fields that were required for copying "KPI_xxx".  The code below take this into account.

Useful Edit Field Button

Here is some useful code that prompts for a field name, field value and field type.  If the field exists and has a value, it automatically defaults the new value to the existing value.

Sunday, 6 March 2011

Delete your Cache with LotusScript

I found this bit of code recently and it saves quite a lot of time by not having to close notes, find the data directory, delete cache.ndk and restart notes. Keep this in a button somewhere (perhaps a draft email) or place it on a database open event. It could also be used to help support users without being at their desk should a TopDesk call arrive at your desk.

Append text to Richtext field

This allows you to post a number of text fields into a single RT field.  We use this to send information from a number of fields in a memo document.

You pass in the RTField, the title you want to display, the fieldname of the contents and the doc.  The result is something along the lines of ...

Convert Document to XML

Here is a small sub that creates an xml file of all the fields available in a document that it is passed.

Simulate Keystokes

From time to time it is often require to perform an operation for the user.  For example, I wanted to exit notes, which I know you can do in other ways, like from the Workspace class, but it was not working in this situation.


Handy Selected Documents Totals

This code snippet take a view, takes the selected documents and adds together a value from a particular field.