This is the sixth part of articles discussing Project Detail Page enhancements:
- Show/hide a field depending on the value of an internal field on the same page
- Show/hide a field depending on the value of an Enterprise Custom field on the same page
- Show/Hide a field based on the value of an internal field using REST
- Show/Hide a field based on the value of an Enterprise Custom Field without Lookup Table using REST
- Remove Time from Enterprise Custom Fields on Project Detail Pages
- Remove Prefix from Enterprise Custom Fields on Project Detail Pages
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.
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 replacedvar 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.