mandag den 20. oktober 2014

Project Server Read only Custom Fields (Javascript)

PROJECT SERVER - Make Custom Fields Read Only

The fields on the PDPs (Project Detail Pages) is always editable unless you make them read only in a workflow stage or use the calculated field as suggested in my other post.
If you want to make a custom field read only without using aditional custom fields you have to do it through Javascript.
In the following i will explain how we can make custom fields read only through Javascript.

Insert a Content Editor webpart to the PDP page where the field you have the field that should be made read only.

Select the webpart and from the ribbon select HTML->Edit HTML Source.
Copy/Paste the following code into the Content Editor webpart.

<script type="text/javascript">
function makeReadOnly()
 var elements=document.body.getElementsByTagName("INPUT");
 for (index=0; index < elements.length;++index)
   if(elements[index].title=="Project Number") //Field name

 setTimeout(makeReadOnly, 500);
setTimeout(makeReadOnly, 100);

Replace “Project Number” with the field you want to make read only.

Click OK and Stop Editing and the field name should be updated.
Now the field is read only when viewing the PDP.

Ingen kommentarer:

Send en kommentar