Thursday, March 15, 2012

Showing horizontal notes data as vertical in view

Today at work, I needed to transfer some data from a Notes application to SQL. The documents in question were horizontal.

An example of what I mean:
An order form in Notes with five order lines. For each line, there may be five fields that contains information about the order. Making it a total of 25 fields for five order lines.


Traditionally, if you want to show this data in a regular notes view, you have to have a column per field.


Thanks to the way the index is organized in a Notes view, you can show this data vertically using Show multiple values as separate entities.


A summary of the technique:
  • In each column, create a list of the field values that you want to show
  • Each column list has to have equal amount of values
  • Each column has to have Show multiple.. property enabled
  • Only the first column can be sorted (it can be categorized), or you end up with a lot of rows.
    This is probably due to how the index is organized/matching of multiple values

Here's the demoapp I took the screenshots from:
>> Download

Take a look at the Vertical view to see the technique I used.

Thanks to this technique, I can simply pull the data from a view using view entries/column values/send row by row to a stored procedure in SQL. The alternative would be to write code for each field.

Share and enjoy! :)

Thursday, March 8, 2012

Patch for bug in XSP.partialRefreshGet/-Post in 8.5.3

Someone made a really stupid mistake in the code for XSP.partialRefreshGet/-Post in 8.5.3..

I won't go into specifics of the code as I'm uncertain if it's breaking some license. Let's just say that if they moved a line of code four or five lines upwards, there wouldn't be any bug.

I wrote a simple patch for the bug. Put it in a CSJS library, and your code will work like it did on 8.5.2 (unless I made a stupid mistake).

/**
* Fix for bug with partialRefreshGet/-Post in 8.5.3
*/
(function(){
var oldPartialRefreshGet = XSP.partialRefreshGet;
XSP.partialRefreshGet = function( targetId, options ){
// Convert to array
var argsArray = Array.prototype.slice.apply( arguments );

if( argsArray.length > 1 ){ argsArray[1] = argsArray[1] || {}; }
if( argsArray.length === 1 ){ argsArray.push( {} ); }

oldPartialRefreshGet.apply( XSP, argsArray );
};

var oldPartialRefreshPost = XSP.partialRefreshPost;
XSP.partialRefreshPost = function( targetId, options ){
// Convert to array
var argsArray = Array.prototype.slice.apply( arguments );

if( argsArray.length > 1 ){ argsArray[1] = argsArray[1] || {}; }
if( argsArray.length === 1 ){ argsArray.push( {} ); }

oldPartialRefreshPost.apply( XSP, argsArray );
};
})();


This code should be forwards compatible with future API updates, as it doesn't assume number of arguments in function.