Lotus Connections Profiles – using JavaScript to translate data for TDI

I have been working with Lotus Connections lately and wanted to share a tidbit of code for the profiles database population step.

During the population of the profiles database from Domino LDAP using TDI (Tivoli Directory Integrator) I needed to translate country names to the matching ISO country code as this is what is used in Lotus Connections. To do this you can write a Javascript function in profiles_functions.js and map it in map_dbrepos_from_source.properties. The documentation on this is very lacking but through some trial-and-error and with a little help from Mac i cracked it.

Below is the function I wrote (with only a few countries) to show how to write the function which isn’t apparent at all. The error output from TDI simply indicates a “parse error” if your Javascript is wrong for whatever reason.

I hope this can save someone some time…

The tricks:

  • Define “fieldname” as a parameter to the function. I don’t use it but at least one parameter is required.
  • Use the available “work” variable to get data from the backend LDAP directory using the getAttribute method.
  • Use the available “system” variable to create a new attribute to replace the one we find.
  • Return the constructed attribute to have it show up in the profiles database.
  • The Javascript is actually accessing Java objects in the backend. Keep this in mind when comparing Strings – remember to use String.equals!

map_dbrepos_from_source.properties

PROF_ISO_COUNTRY_CODE={func_xlate_country}

profiles_functions.js

function func_xlate_country(fieldname) {
  // init arrays for translation
  var iso_codes = new Array("DK", "IE", "DE");
  var iso_ctry = new Array("Denmark", "Ireland", "Germany");

  // get attribute
  var ctry = work.getAttribute("c");
  if (null != c) {
    // get value from attribute
    var val = ctry.getValue(0);

    // loop array
    for (var i=0; i<iso_ctry.length; i++) {
      // match country name from attribute against current
      // array position
      if (val.equalsIgnoreCase(iso_ctry[i])) {
        // found one - create new attribute to hold
        // our translated value and set it
        ctry = system.newAttribute("c");
        ctry.addValue(iso_codes[i].toLowerCase());
      }
    }
  }

  // return attribute to TDI
  return ctry;
}

Lotus Connections and FeedDemon 2.5 RC1

I’m now on the Lotus Connections site and I think it’s great. Looks very promising though I haven’t played enough with it yet. I very much like the Dogear functionality though I need to find a blog to post links to it from FeedDemon as I do with del.cio.us using the “blog this” functionality. It appears there is an API so it should be fairly easy to figure out.

I haven’t Googled it yet so someone might already have figured it out.

Also – upgraded to FeedDemon 2.5 RC1 without any problems. I have been running the betas since beta 1 without any issues what so ever (apart from occasional hangs which I blame on IE 7 more than FeedDemon). If you’re not already using FeedDemon you really owe it to yourself and your feed reading to check it out.