onsdag den 26. marts 2014

A resource availability contour cannot go outside the range of the resources earliest and latest availability dates

A resource availability contour

Encountered a problem at one of our customers today Project Server 2010 installation today. In Resource Center when i try and edit a resource's "Latest Available Date" or "Earliest Available Date" i get an error saying:
A resource availability contour cannot go outside the range of the resources earliest and latest availability dates
I experience this error before, but always forget the reason for it.

The reason is that the resource have custom availability defined, this can only be defined in the MS Project client. An indication that the resource has custom availability is also that "Current Max. Units (%)" is grayed out (inactive).

To solve the problem you need to select the resource and open it up in the MS Project client (3 button on the Ribbon). In the client doubleclick the resource name and modify the values in the "Resource Availability" grid to match what you wanted to type in "Latest Available Date" or "Earliest Available Date".

If you don't have MS Project installed you are out of luck.

Note: a third party program could also have modified the custom availability.

For more information also check out this link:
http://office.microsoft.com/en-us/project-help/set-working-times-vacations-and-holidays-for-your-project-HA001224299.aspx

fredag den 21. marts 2014

Project Server 2013 Service Pack 1 download and install

Project Server 2013 and SharePoint 2013 SP1 is out

Service Pack 1 is out for Project Server 2013. Download and install it now to recieve all the hotfixes and a couple of new features.

Don't forget to first install SharePoint SP1 and run the configuration wizard afterwards.
1. Download and install SharePoint SP1: 
2. Download and install Project Server SP1: 
3. Restart the windows server 
4. Run the SharePoints Configuration wizard
5. If any of your users are using the MS Project client don't forget to have them update to the latest version:

Sharepoint/Project Server App with javascript and Web Part

Getting Project Server code to run in a AppPart

Today I tried to get project server CSOM/javascript code to run within an app part. This caused a lot of troubleshooting and guessing to get it to work.
By simply adding the ps.js library to the app part page I kept getting an error.
Library:
<script type="text/javascript" src="/_layouts/15/ps.js"></script>
Error:
"executeordelayuntilscriptloaded is undefined"
Then I tried to use ScriptLink to load the library but got the same error.
<SharePoint:ScriptLink runat="server" Name="ps.js" Localizable="false" OnDemand="False" LoadAfterUI="True"></SharePoint:ScriptLink>

The code I was trying to run was very simpel and worked fine if I added it to a normal aspx page.

 $(document).ready(function () {
    var projContext = PS.ProjectContext.get_current();
 
    var projects = projContext.get_projects();
    projContext.load(projects, 'Include(Name, CreatedDate, Id)');
    projContext.executeQueryAsync(
       function () {
          var projEnum = projects.getEnumerator();
          var sp = "";
          while (projEnum.moveNext()) {
             var p = projEnum.get_current();
             sp = sp + ";" + p.get_name();
          }
          $("#projects").html(sp);
       }, function (sender, args) {
          alert('Error Load projects: ' + args.get_message());
    });

 });

After many tries, forum question and different enviroments I finnaly found the solution. The thing i missed was that ps.js had some SharePoint dependencies besides sp.js and sp.runtime.js. By including the following libraries I finally got it to work.
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
Now i could use the AppPart but the result after the function executeQueryAsync failed with the message:
Unexpected response from server. The status code of response is '404'. The status text of response is 'Not Found'.
After some more digging and mails with the Project team in Redmond I got the suggestion to try and add the following line:
projContext.set_isPageUrl(SP.ClientContext.get_current().get_isPageUrl());
And suddenly everything started to work and I could load the projects through the AppPart.

The complete AppPart code can be found below:

<%@ Page language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<WebPartPages:AllowFraming ID="AllowFraming" runat="server" />

<html>
<head>
    <title></title>

    <script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="/_layouts/15/init.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="/_layouts/15/ps.js"></script>

    <script type="text/javascript">
        'use strict';

        // Set the style of the client web part page to be consistent with the host web.
        (function () {
            var hostUrl = '';
            if (document.URL.indexOf('?') != -1) {
                var params = document.URL.split('?')[1].split('&');
                for (var i = 0; i < params.length; i++) {
                    var p = decodeURIComponent(params[i]);
                    if (/^SPHostUrl=/i.test(p)) {
                        hostUrl = p.split('=')[1];
                        document.write('<link rel="stylesheet" href="' + hostUrl + '/_layouts/15/defaultcss.ashx" />');
                        break;
                    }
                }
            }
            if (hostUrl == '') {
                document.write('<link rel="stylesheet" href="/_layouts/15/1033/styles/themable/corev15.css" />');
            }
        })();
        function Run() {
            $(document).ready(function () {
                var projContext = PS.ProjectContext.get_current();
                projContext.set_isPageUrl(SP.ClientContext.get_current().get_isPageUrl());
                var projects = projContext.get_projects();
                projContext.load(projects, 'Include(Name, CreatedDate, Id)');    // Run the request on the server.    
                projContext.executeQueryAsync(
                function () {

                    var projEnum = projects.getEnumerator();
                    var sp = "";
                    while (projEnum.moveNext()) {

                        var p = projEnum.get_current();
                        sp = sp + ";" + p.get_name();
                    }
                    $("#projects").html(sp);
                }, function (sender, args) {
                    alert('Error Load projects: ' + args.get_message());
                    $("#projects").html(args.get_message());
                });

            });


        }
        Run();
    </script>
</head>
<body>
    <div id="projects">Loading...</div>
</body>

</html>

onsdag den 12. marts 2014

Project Server - Change field name on PDP for standard fields (like the Owner field)

Project Server - Change owner field name on PDP

The field names on the PDPs (Project Detail Pages) has been preselected on the standard fields for a project. If you want to change the Owner to something else it is quite difficult. In the following i will explain how we can change this field through the Content Editor webpart.
To change the owner field add a Content Editor webpart to the PDP page where the field is inserted.

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">
    var old_name = "Owner";
    var new_name = "Ansvarlig";
    var ttnA = document.getElementsByTagName("div");
    for (var j = 0; j < ttnA.length; j++) {
        var orig = ttnA[j].innerHTML;
        var stripped = orig.replace(/^\s*/, "").replace(/\s*$/, "");
        if (stripped == old_name) {
            ttnA[j].innerHTML = new_name;
        }
    }
</script>

Replace “Owner” with the field you want to change the name for and replace “Ansvarlig” with the value you want to display the field as.

Click OK and Stop Editing and the field name should be updated.