Point Deep

Mundeep's Tech Blog

Hiding Mapped Property Images in User Profiles

Posted by mundeep on September 9, 2008

While working with Sharepoint User Profiles I have had to perform a hack to remove Mapped property images or Warning property images from the Sharepoint User Profiles edit page. Using the default ShowMappedIcon or ShowWarningIcon properties of the “UserProfileEditor” control easily allow you to hide the warnings and mapping information however it destroys the layout of the rest of the editing page by missing lots of table cells and results in an ugly looking page.

As a result i had to instead leave ShowMappedIcon=”true” and then use the following javascript to hide all the mapping images and wording:

/// <summary>
/// Hide mapping text and images.
/// </summary>
function clearMappingDisplay() {
    try {
        //Hide Mapping Images
        //Find all images on page
        var images = document.getElementsByTagName('IMG');
        for (var i=0; i < images.length; i++) {
            var curImage = images&#91;i&#93;;
            //If image is for "Mapped" property
            if(curImage.alt == "Mapped") {
                //Replace image with blank.gif & hide image
                curImage.src = curImage.src.replace("mapped", "blank");
                curImage.style.visibility = "hidden";
            }
        }
        //Hide mapping text
        //Get tblMain container
        var mainTable = document.getElementById('tblMain');
        //Get all tables within main table
        var subTables = mainTable.getElementsByTagName('TABLE');
        for (var i=0; i < subTables.length; i++) {
            var curTable = subTables&#91;i&#93;;
            //Find the table that includes the mapping text
            if(curTable.innerText.indexOf("mapped for profile import") > -1) {
                for (var k=0; k < curTable.cells.length; k++) {
                    var cell = curTable.cells&#91;k&#93;;
                    //Find the cell that contains the mapping text
                    if(cell.innerText.indexOf("mapped for profile import") > -1) {
                        //Clear the mapping text
                        cell.innerText = "";
                    }
                }
            }
        }
    }
    catch (ex) {
        //TODO: Handle error.
    }
}
//Ensure sharepoint runs the clearMappingDisplay method on Page (Body) Load
_spBodyOnLoadFunctionNames.push("clearMappingDisplay");
Advertisements

2 Responses to “Hiding Mapped Property Images in User Profiles”

  1. CreatoX said

    I love to implement this code… but do not know how.

    Wherever I place the javascript into editprofile.aspx, is resulting in an error.

    Could you please give me the complete writing of the aspx file?

  2. Ty said

    CreatoX, did you figure this out? Where would I place this code?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: