Wednesday, October 19, 2016

Boom! OnePlus Dash for Diwali Level 1 'Bloom'! #OnePlusDiwaliDash

Boom! OnePlus Dash for Diwali Level 1 'Bloom'! #OnePlusDiwaliDash

Friday, February 19, 2010

Generating PDF Documents From Templates

Generating PDF documents on the fly isn't exactly rocket science and - with the help of tools like iText -

http://codestore.net/store.nsf/unid/BLOG-20091123-0347
in reference to: Generating PDF Documents From Templates | Mon 23 Nov 2009 | Blog | CodeStore (view on Google Sidewiki)

XPage XAgents, REST, and IBM Lotus Notes Domino Web Application Development | dominoGuru.com

XPage XAgents, REST, and IBM Lotus Notes Domino Web Application Development | dominoGuru.com

Posted using ShareThis

Simple LotusScript NotesDocumentCollection Iteration

Sometimes a StampAll just doesn't give you enough flexibility or control when dealing with a NotesDocumentCollection. Sometimes you need to some logic behind each NotesDocument update. For those situations, we tend to use a technique called iteration... which sounds really awesome and consultant-like, but basically boils down to creating a looping function within your LotusScript.



How To

Function setManager(col As NotesDocumentCollection) Dim s As New NotesSession Dim doc As NotesDocument Dim nab As New NotesDatabase(s.CurrentDatabase.Server, "names.nsf") Dim nabview As NotesView Dim nabcol As NotesDocumentCollection Dim nabdoc As NotesDocument Set nabview = nab.GetView("people") Set doc = col.GetFirstDocument Do Until(doc Is Nothing) Set nabcol = nabview.GetAllDocumentsByKey(Join(doc.GetItemValue("submitter"), ""),True) Set nabdoc = nabcol.GetFirstDocument Call doc.ReplaceItemValue("manager", nabdoc.GetItemValue("manager")) Call doc.Save(True, False, True) Set doc = col.GetNextDocument(doc) Loop End Function

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Not a big change here, but using the getNextDocument steps through the NotesDocumentCollection and scales much better than the dreaded getNthDocument.

Conclusion

So what have we learned?

1. There's no environment in the world where the above scenario would actually exist.
2. I suck at creating Use Cases...
3. getNthDocument is evil. If you come across it in your production code, you might as well just unplug the Domino server.
4. getNextDocument-based iterations scale!

And, most importantly, NotesDocumentCollection iteration is an extremely powerful technique that can allow you to process large numbers of NotesDocuments with applied logic at the individual NotesDocument-level.
There are several methods complete with built-in functions in LotusScript that allow you to iterate through NotesDocumentCollections, NotesViewEntryCollections, and such... so I'll start off by defining a simple use case, and then showing you how not to iterate through a given NotesDocumentCollection, and then ultimately showing you a solid approach to NotesDocumentCollection iteration!

Use Case

A scheduled Agent for a simple Project Management application will evaluate each new NotesDocument since last run and -- since we're going for simple here -- update the manager NotesItem with the value stored in the submitter's Person Document in the Domino Directory. Since this is an ideal world, every Person Document manager is both defined and contains the common name matching the manager's own Person Document.

Author's Note: Yeah, this would never happen, but this is a use case for iteration, not chasing down the manager NotesItem values... so go with me on this one.

How not to...

The below LotusScript uses the getNthDocument function to loop through a supplied NotesDocumentCollection and perform whatever NotesDocument application logic is needed (in this case, a Domino Directory lookup and NotesDocument update & save).

Function setManager(col As NotesDocumentCollection) Dim s As New NotesSession Dim counter As Integer Dim doc As NotesDocument Dim nab As New NotesDatabase(s.CurrentDatabase.Server, "names.nsf") Dim nabview As NotesView Dim nabcol As NotesDocumentCollection Dim nabdoc As NotesDocument Set nabview = nab.GetView("people") counter = 0 Set doc = col.GetFirstDocument Do Until(counter > col.Count) Set doc = col.GetNthDocument(counter) Set nabcol = nabview.GetAllDocumentsByKey(Join(doc.GetItemValue("submitter"), ""),True) Set nabdoc = nabcol.GetFirstDocument Call doc.ReplaceItemValue("manager", nabdoc.GetItemValue("manager")) Call doc.Save(True, False, True) counter = counter + 1 Loop End Function

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

If you have 5 NotesDocuments, this isn't that bad of an approach. I still wouldn't use it though and the reason is pretty simple: it scales horribly, and we're coding for the species here people!


in reference to: Simple LotusScript NotesDocumentCollection Iteration | dominoGuru.com (view on Google Sidewiki)

Monday, January 5, 2009

@SetTargetFrame and @URLOpen

To open url in new window using formula language, make use of @SetTargetFrame and @URLOpen

Below is the illustration -

@SetTargetFrame("_blank");
@URLOpen(urlstring)

Sunday, November 9, 2008

Search on single field using SearchView

If you want to search a view for specific field value then you can use SearchView as shown below.

Ex. If you want documents having "Yes" as value for "IsActive" Field then you can use SearchView as given below.

http://server/dbname.nsf/viewname?SearchView&QUERY=FIELD%20IsActive=Yes

Wednesday, October 22, 2008

"splice" - JS method to add/remove array elements

Definition and Usage

The splice() method is used to remove and add new elements to an array.

Syntax

arrayObject.splice(index,howmany,element1,.....,elementX)

 

Parameter

Description

index

Required. Specify where to add/remove elements. Must be a number

howmany

Required Specify how many elements should be removed. Must be a number, but can be "0"

element1

Optional. Specify a new element to add to the array

elementX

Optional. Several elements can be added

 


Example

In this example we will create an array and add an element to it:

<script type="text/javascript">
var arr = new Array(5);
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
document.write(arr + "<br />");
arr.splice(2,0,"Lene");
document.write(arr + "<br />");
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Lene,Stale,Kai Jim,Borge

 


Example

In this example we will remove the element at index 2 ("Stale"), and add a new element ("Tove") there instead:

<script type="text/javascript">
var arr = new Array(5);
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
document.write(arr + "<br />");
arr.splice(2,1,"Tove");
document.write(arr);
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove,Kai Jim,Borge

 


Example

In this example we will remove three elements starting at index 2 ("Stale"), and add a new element ("Tove") there instead:

<script type="text/javascript">
var arr = new Array(5);
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
document.write(arr + "<br />");
arr.splice(2,3,"Tove");
document.write(arr);
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove


Ref Link : http://www.w3schools.com/jsref/jsref_splice.asp