Earlier today Julian Buss asked in a blog post about how to get the unid of a selected document in the iNotes List View. Even though I wrote that chapter in the Extension Library book, I was a little baffled myself. Even after I re-read what I’d written, I struggled to work out where I had found out about ext.tumbler and ext.item. I read what I’m sure others have, that I wrote that many of the events worked the same as the iNotes Calendar View.

I eventually tracked down where I had found out about the ext object – the Custom Event Handler tab on the DWA_ListView2 XPage in the Extension Library Demo database. There are examples using it in the onCellDblClick event of the iNotes List View control. This was where I had found out about ext.tumbler for capturing the row clicked and ext.item for getting a handle on the JSON object for that row – remember that these two iNotes view controls use JSON, so the entrydata is a JSON object.

This was where I made an error. Mea culpa.

I assumed that all events in the iNotes List View accessed the entries the same way. They don’t. onCellClick and onCellDblClick can access the ext object. However, the other events don’t. They access the entrydata for the relevant row in the same way that the iNotes Calendar View access it – items[0].

But things are rarely that straightforward. The iNotes Calendar View accesses the entry’s UNID using items[0].unid, as you can see in the onOpenEntry event on the calendarView Custom Control.

So knowing that items[0] gets the entrydata, knowing it’s a JSON object, knowing the object’s properties can be seen using something like Firebug, we can identify the relevant property for the UNID. However, the relevant property is @unid.

iNotes ListView

So we can’t use items[0].@unid because the @ symbol has a specific meaning in JSON. With a little help from my friends (JSON is not my strength!) and items[0][“@unid”] works to get a handle on the UNID in the relevant events – onContextMenu, onDeleteEntry, onNewEntry, onOpenEntry and onSelectEntry. (Bear in mind that in some cases you may need to check whether items[0] is null.)

So adding the following to the onOpenEntry event, and when you double click, you get the UNID in an alert:

alert("UNID is " + items[0]["@unid"]);

Now we know how to get a handle on any property in the iNotes List View. In the systemColumns property of the REST Service, I’ve selected NotesID and UNID, and they’re outputted as @noteid and @unid. The other columns use the programmatic name from the View design element. If you add columns to the REST Service using the restViewColumn object, I would expect that the programmatic name will be the columnName property of the restViewColumn. But with Firebug, you can drill into the REST service and find out any property name from the items[0] JSON object.

So now back to the iNotes Calendar View. With that too you can drill into the JSON, as below:

iNotes Calendar View

You’ll notice one obvious fact. No matter which of these JSON objects is items[0], nothing has a property called just “unid”. Trying to access the other properties, it’s equally challenging. So with a little digging I managed to get this code:

var obj=items[0];
for (var key in obj) {
alert(key + ": " + obj[key]);
}

Put this in the onSelectEntry event of the iNotes Calendar View, for example, and it accesses the items[0] object, loops through the JSON object and throws up an alert for each property giving the property name and value. You’ll see that unid is there, along with all the other properties.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top