Showing posts with label notes. Show all posts
Showing posts with label notes. Show all posts

7/22/2013

Render View Column Color in a XPage

In Notes you can easily change the color of columns (background and text) with a list of integers in a hidden column. In Xpages it is not as easy, you need to either translate the colors to hex, oder into style classed that do the work for you. I found an interesting article on how to transform the information into styles, you can find it here, but i wanted to have the flexibility to change the notes view and have the xpage change automatically according to it, too.



So i came up with this little function that can be used in a computed style for a row, or a single cell. Make sure to use the advanced properties of the view to make the column entry accessible, in this example i chose "rowData" as the name for the variable, then just use the function like this

getColumnColorStyle(rowData, 3, "width: 15px;");

Its as easy as that, and if you put the function into a script library, you can make it accessible to all of your pages easyily (i chose to use a new namespace for all of the tool functions i use, but here you have got the plain function).

function  getColumnColorStyle(rowData, column, baseStyle){
   var styleString = baseStyle?baseStyle:"" ;
   var arr=rowData.getColumnValues().get(column);
   if(arr){
      var f = function twoDigitHex(anInteger){
         return ("00"+parseInt(anInteger).toString(16)).right(2);
      };
      var hexcolor = "#"+f(arr[0])+f(arr[1])+f(arr[2]);
      if(hexcolor!="#000000" )
         styleString+= "background-color: "+hexcolor+";";
      if(arr.length > 5){
        hexcolor = "#"+f(arr[3])+f(arr[4])+f(arr[5]);
        if(hexcolor!="#000000" )
           styleString+= "color: "+hexcolor+";" ;
      }
   }
   return styleString;
}

7/24/2012

Open the Users Mail Database

To open the mail database of the current user, just use the Method "OpenMail" in a NotesDatabase Object. It feels a bit awkward at first, but actually the object will update itself to contain the database immediately. Easy!

Dim db as New NotesDatabase("","")
Call db.OpenMail
Dim doc as NotesDocument
'now just prepare am email and open it in the client, ready to be sent.
Set doc=db.CreateDocument()
Call doc.ReplaceItemValue("Form","Memo")
Call doc.ReplaceItemValue("SendTo","John.Doe@Example.com")
Call doc.ReplaceItemValue("Subject","Hello World")
Call doc.ReplaceItemValue("Body","This Mail will now be opened and ready to be sent by the user.")
Dim ws as New NotesUIWorkspace()
Call ws.EditDocument(true, doc)

7/18/2012

How To Search your Workspace for Code

This is very useful for those code changes that just might span over different design elements. Just hit the "Search" Menu entry that is available in designer and enter the types of design elements that you want to search. Please notice that the standard setting will be quite slow, so here are some (source code) extensions you will want to include when developing xpages and notes. You will want to exclude everything that is binary, because you wont find anything in it.
  • *.xsp XPages and Custom Controls
  • *.js Client Side Java Script Library
  • *.jss Server Side Java Script Library
  • *.java Java Source Code
  • *.css CSS File
  • *.lss Lotus Script Library
  • *.lsa Lotus Script Agent
  • *.form Form DXL Representation
  • *.subform Subform DXL Representation
  • *.view View DXL Representation
All those other extensions can be found out in the "Package Explorer" view of the eclipse framework in the designer.

7/11/2012

Converting Times to your Servertime in a Nutshell

A quick method to convert UTC DateTime to the current servers local time. I use this for a rest webservice that accepts UTC/GMT timestamps from an iPhone to make sure all times in the database are in the correct timezone, and still accurate. This code will go into the "input translation" section triggered by the "compute with form".

timestring := month+"/"+day+"/"+year+" "+hour+":"+minute+":"+seconds+" GMT";
time := @TextToTime(timestring);
result := @TextToTime(@TimeToTextInZone(time;@GetCurrentTimeZone;"D0T0"));

7/02/2012

XPages Options for Development in a Team

There are some (new?) interesting options you should know about if you develop with xpages, especially when developing in a team. I just stumbled onto it, and it explains a lot of weird problems with a coworker.

Manually recompile xpages is especially helpful, because if you save your custom control, every dependency is recompiled. If you work on a server and another colleague does something similar, you might be ending up with a big mess of classes that do not match each other, and not even recognize this (and the errors resulting from this are not very helpful, too).

Additionally i found it quite annoying to get the id of labels instead of the actual code, so this is fixed now, too. Joy!