Project Online / Project Server: Project Detail Pages - Enhancements (Part 6)–Remove Prefix from Enterprise Custom Fields on Project Detail Pages

2019-02-19 | Barbara.Henhapl

This is the sixth 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

It is a common practice to use a prefix for Enterprise Custom Fields. In Project Center views you can modify the column headers to hide this prefix.

image

Since there is no possibility configure Enterprise Custom Field names on PDPs, you will need to add some code to adjust field labels.

On Project Detail Pages, there is no such option available. However, as an administrator, you can apply some JavaScript to show dates without time. The following script will remove a defined prefix from all Enterprise Custom Field names.

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

//Label to be replaced
var Prefix = "BH ";

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

function MainFunction() {
    RemovePrefix();
}

function RemovePrefix(){
	$(".ms-accentText").each(function() {
	    var text = $(this).text(); 
	    $(this).text(text.replace(Prefix, ''));
	});
}    
</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-6)-Remove-Prefix-from-Enterprise-Custom-Fields-on-Project-Detail-Pages