Project Online / Project Server: Project Detail Pages - Enhancements (Part 7) – Hide Impact Ratings on Project Detail Page “Strategic Impact”

2019-02-24 | Barbara.Henhapl

This is the seventh part of articles discussing Project Detail Page enhancements:

  1. Show/hide a field depending on the value of an internal field on the same page
  2. Show/hide a field depending on the value of an Enterprise Custom field on the same page
  3. Show/Hide a field based on the value of an internal field using REST
  4. Show/Hide a field based on the value of an Enterprise Custom Field without Lookup Table using REST
  5. Remove Time from Enterprise Custom Fields on Project Detail Pages
  6. Remove Prefix from Enterprise Custom Fields on Project Detail Pages
  7. Hide Impact Ratings on Project Detail Page “Strategic Impact”
  8. Disable "Project Owner" Button on Project Detail Page

For a description for preparation of a Project Detail Page for JavaScript, see General Preparation

If you are using “Strategic Impact”, there are 5 Project Impact Statements by default:

  1. None
  2. Low
  3. Moderate
  4. Strong
  5. Extreme

In this sample, we will hide the ratings Low and Strong. To hide these ratings, we set description for these ratings to “DO NOT USE”. With this specific text we are able to hide these ratings on a PDP.

image

After adding below code, PDP Strategic Impact will not display “Low” and “Strong”:

image

Use this code to implement the solution:

<!-- Change path for jquery-2.1.1.min.js --> 
<script type="text/javascript" src="/sites/PWA/Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">

//Project Impact Ratings - Rating description to be hidden
var Text4HideRow = "DO NOT USE";

$(document).ready(ExecuteOrDelayUntilScriptLoaded(MainFunction, "sp.js"));

function MainFunction() {
    HideDoNotUse();
}

function HideDoNotUse() {
        var TRow = document.getElementsByTagName("tr");
        for (var i = 0, k = TRow.length; i < k; i++) {
	//PDP Strategic Impact contains embedded tables. To only hide a row of inner table, we need to identify row with "TRow[i].innerText.length < 20"
            if (TRow[i].innerText.indexOf(Text4HideRow) > 0 && TRow[i].innerText.length < 20) {
                TRow[i].style.display = "none";
            }
        }
    }
</script>

Copy above code into a text editor, modify at least the marked sections, save with file extension "js" or "html", and upload to your script library.

Categories: Project

Source: https://blog.atwork.at/post/Project-Online-Project-Server-Project-Detail-Pages-Enhancements-(Part-7)-Hide-Impact-Ratings-on-Project-Detail-Page-Strategic-Impact