Pages

Showing posts with label Formula. Show all posts
Showing posts with label Formula. Show all posts

Tuesday, September 10, 2013

Custom sort using @Sort in lotus notes


I happened to cross through a scenario where I had to perform a custom sort in such a way that a list of words appear in a drop down in such a way that "Red" if present always appears first followed by "White" and "Blue" if they are present and the rest of the list must be alphabetically sorted.

I found a close way to do that but not the best solution though. It took me quite a while to understand the way the parameters "$A" and "$B" were used in the @Sort function.

I use a list named a s"myList" as an input parameter. The list elements present inside my list is as follows

Blue : Custom : XCustom : Red : DCustom : White

Take a look at the following code.

@Sort(myList; [CustomSort]; @Do(
  @If(
      @UpperCase($A)="RED";-1;
@UpperCase($A)="WHITE" & @UpperCase($B)="RED";1;
@UpperCase($A)="WHITE" & @UpperCase($B)!="RED";-1;
@UpperCase($A)="BLUE" & (@UpperCase($B)="WHITE" | @UpperCase($B)="RED") ;1;
@UpperCase($A)="BLUE" & !(@UpperCase($B)="WHITE" | @UpperCase($B)="RED") ;-1;
@UpperCase($A)>@UpperCase($B)
   )
) )

The out put that I have obtained is as follows

Red : White : Blue : Custom : DCustom : XCustom 

When I change the last line of code to @UpperCase($A)<@UpperCase($B) my out put becomes
Red : White : Blue : XCustom : DCustom : Custom 

It returns two types of values 1 and -1. The confusion was, It is supposed to return an integer equivalent for @true and @false which are to my understanding 1 and 0 respectively.

I dont know how was one able to think about the scenario of using -1 as a return type which was not documented in Designer help. It works great.

As per my understanding if you return
1 - it means $A will be put behind $B in the list after the comparison occurred
0 or -1 - it means $A will be put in front of $B in the list after the comparison occurred.

-2 ( and probably all other negative number) is treated like 0 as well O.o

Tuesday, September 3, 2013

Colors in Lotus Notes View Columns

I always wanted to document this, but often felt lazy about doing it. Thus this got delayed by almost 4 and half years. Can you believe that? I can. I know I am better at doing stuffs more worse than this.

This post is typically about how you give different colors to different columns in Notes Client. Actually there is no such thing. Hence as always we end up doing simple work arounds. Let me give you a visual sneak peak before you end up reading my entire post and feel bored

Thats looks color full doesn't it :). The trick behind these colored columns with custom backgrounds are using hidden columns with "Use value as colors" enabled with a column formula like

backgroundColor:textColor where each of these would assume a value between 000000 to ffffff or 0:0:0 to 255:255:255. Refer to following image for more details


If you take a closer look at the image, you will be able to see that I am referring to three small columns with no titles and the two important properties "Use value as color" and "Hide column" enabled.

Make a note of the way in which I had assigned the color values to the variables. They are not in quotes. I have assigned the numbers colon separated just as is. So these variables are typically arrays containing three color codes as its elements

Saturday, February 9, 2013

Change native lotus notes database display format - view index on top and view in bottom

Every Lotus Notes Professional would be aware of the way lotus domino databases would be displayed on the notes client if no custom framet has been configured, It would be something like the following.

I just messed up the view names for personal reasons. So I think I make sense here. View index would be on the left margin and the view being displayed or selected will be displayed ont the right margin.

But did you ever know that we have an option to change that to the following silly format :)

Believe me I did not take two different screen shots and place them together. This is a screen shot as it is from the notes client. Yes view index is on top and the view being displayed or selected will be displayed in the bottom pane like a preview pane and yes you can have a separate preview pane for the view as well.

Its just that your display will be messed up and will be ackward. I sont recollect a scenario where this would be of advantage as far as lotus notes client applications are concerned. Atleast, I now know that I have such an option and can do it. May be I would use it to statle someone in the future hi hi :)

Yes I dream a lot :)

By the way, as far as I know you need to use the following @commands to get this done.

@Command([ViewBelowFolders])

and to get the display back to normal, you can use the following command

@Command([ViewBesideFolders])


Thursday, January 3, 2013

Formula inMemory note - Web Hack

When researching about the _doClick related concepts, I found a hack that might possibly be a serializaied representation of the memory segment where a formula command will be stored in a server.

This sounds funny and frightening to me - "Yin and Yang" concept, if I am not wrong.

Well as usual try the following ridiculous stuff and tell me that I am not crazy.

1. Create/open a form in Lotus Notes
2. Create a button and put some formula code inside it as illustrated in the following screen shot.
3. Now navigate to the HTML tab of the button properties dialog and simply add "<>" in the 'Other' field as illustrated in the previous screen shot .

4. Now preview the form in browser and you will be able to see some thing like this

Discussion points in few forums say that these numbers are memory segment representation sort of stuffs in the server with the domino uses via "_click" field in post data or a &click argument in a url  to trigger and execute these formula commands.

Man this stuff is crazy.

Thursday, June 2, 2011

Get Foldernames on the web


The following is a simple way that would illustrate how one can get the list of names of folders available in a database. In this case I have used a list box to bring up those names. Also you can be specific , with a fourth parameter if you don’t want a folder name from being displayed on the list
@DbCommand( "Domino" ; "FolderList" ;"My Custom First Element" )

 Hope this helps :)

Examples using @DBCommand – A simple way to navigate between pages in an Embedded View

1.       Create a form  and add an embedded view to the same

2.       Now add a couple of buttons namely “<<Prev” and “Next>>”

3.         Now add the following commands to  these functions respectively,
a.        @DbCommand( "Domino" ; "ViewPreviousPage" )
b.       @DbCommand( "Domino" ; "ViewNextPage" )
4.       Now preview the form on the browser and try playing with these buttons.

you will be able to see how the documents being listed in the embedded view changes according to the clicks on these buttons. A simple way to navigate between pages voila….

Hope this helps :)

Thursday, December 16, 2010

Array Base Index and Base in Lotusscript (Option Base 0|1)

I happened to stumble upon the base index of arrays when a colleague of mine came up with a doubt in Base command in lotus script

It was interesting to find the following,

Create a couple of buttons and put the following fragments of code in each of them

option base 0
dim myArray[10] as string
msgbox cstr(lbound(myArray)) '--> this would prompt 0

This means now the array can contain 11 string values, where the index varies from 0 to 10

option base 1
dim myArray[10] as string
msgbox cstr(lbound(myArray)) '--> this would prompt 1

And this means the array can contain 10 string values, where the index varies from 1 to 10

Inference :

Option Base 1 in lotus script implies that the arrays will have a lower bound of 1 as is the case with Formula language

Extra Note :
In case of Java, an array of the following sort say,
String[] x= new String[10]

x shall hold 10 values with indices varying from 1 to 10

Hope this helps :)

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.

Wednesday, April 28, 2010

Forall equivalent in Formula Language - @Transform

I felt amazed when I found the Forall (lotusscript) equivalent in Formula Language.

The command is @Transform. It has a typical syntax that it is difficult for beginners to understand.

The syntax for the command is as follows,

@Transform( list ; variableName ; formula )

The parameter named variableName is the culprit that works in a tricky way. In addition the name of the command itself is no where similar to Forall and hence is used less due to lack of a meaningful name, I suppose.

The following is a little illustration of how to use the function.Assume that the following code is in a button (ofcourse you can copy this into a button),

****************

myList=@Explode("FirstValue,NextValue,LastValue";",");
@Transform ( 
   myList;
   "myListValue";
   @Prompt(1;"";myListValue)
)

****************

This will bring up three prompt with the texts - FirstValue, NextValue and LastValue in each of them respectively.

Here the key is understand how I used the iterator parameter myListValue. First I pass it as a string and there after I use it as if it is a normal variable.

The above mentioned code fragment is equivalent to the following in lotusscript.

****************

dim myList as variant
myList=Split("FirstValue,NextValue,LastValue",",")
Forall  myListValue in myList
   msgbox myListValue
End Forall

****************

Hope this helps :)

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])