0

Probably one of the best snippets on your Utils: getHistoryWalker

How many times did you write the code to find the previous value on a specific field? Long time ago I found a library called “HistoryWalker” and since then its been on my must-have snippets on my utils. This library sn_hw is not “public” available but you can see lot of scripts using it. Quite useful 🙂

    getHistoryWalker: function(grObject,field) {
        var answer = [];
        var previousValue;

        var hw = new sn_hw.HistoryWalker(grObject.getRecordClassName(), grObject.getUniqueValue());
        hw.walkTo(grObject.sys_mod_count);

        do {
            var wr = hw.getWalkedRecordCopy();
            var currentValue = wr.getValue(field);
            if (currentValue != previousValue) {
                previousValue = currentValue;
                answer.push(wr.getValue(field) + '');
            }
        } while (hw.walkBackward());

        return answer;
    },

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Rafael

Leave a Reply

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