3

Before the latest updates, we were able to use Javascript Post Messaging from a VisualForce Home Page Component in order to hide it when empty. For example:

if({!someCondition}) parent.postMessage('empty', '*' );

This strategy doesn't work any more, which leads me to believe that Post Messaging is now broken from embedded VisualForce. It doesn't seem like it should be affected by cross-domain issues for most browsers, but I wonder if that may be in play? I am using a version that lists support.

The solution we have dreamed up, but have not yet started to implement, is to write a batch/trigger that essentially checks {!someCondition} and if it is false, we use the Metadata API to hide the Home Page Component from the Home Page Layout.

Is there still a way to conditionally hide a Home Page Component in real time?

1 Answer 1

0

So this essentially ended up being a dupe of this question, we needed to add the listener using the methods described. Note the Javascript gets executed twice.

To remove a VisualForce Home Page Component whose ApexPage has Id '066XXXXXXXXXXXX':

(function (w) {
    "use strict";
    w.addEventListener("message", function () {
        var body = document.getElementById('bodyCell'),
            toRemove = document.getElementById('066XXXXXXXXXXXX');
        if (body && toRemove) body.removeChild(toRemove);
    });
})(window);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .