Using recordWatch for Service Portal in Jakarta

Version 2

    One of the things I love about Portal is the ability to leverage the recordWatch functionality in order to create real-time experiences.

    In a recent workshop, we created a few custom widgets that do rely on recordWatch. While doing so, the developers, who were using Jakarta instances found that their recordWatch callback values for the data object would be undefined, whereas it was perfectly working for everybody on Istanbul or Helsinki, if recordWatch was initialized as per our documentation.

     

    Looking at the browser console for both objects, it's very obvious where that issue comes from:

     

    Istanbul recordWatch Debug

    RecordWatchDumpIstanbul.png

    Jakarta recordWatch Debug

    RecordWatchDumpJakarta.png

     

    While in Istanbul, there were two objects (name & data), in Jakarta there is only one object with data now being part of the name object.

    If you have widgets relying on the actual data returned within data object, those will inevitably break with Jakarta as data.yourVariable will be undefined.

    This is indeed not a bug, but an intended change, which unfortunately didn't trigger the necessary update of the docs article (the docs team is aware of that change and will update accordingly ASAP). The reason beyond this change is, that there was an issue where the callback triggered multiple times when using recordWatch on multiple widgets with the same filter, possibly causing performance issues. This is now fixed, but it requires a new syntax when leveraging recordWatch. Now you can access your data like this: name.data.myVariable as opposed to data.myVariable.

     

    Hopefully this post will save you some headache.