Best practices for writing JavaScript for Project Online – Part 1

Checking the Web Part page design mode

In this series of blogs, I’ll share some the practices I use to write better JavaScript to customise Project Online screens.

The first tip is about detecting the web part page edit mode. Frequently, we write scripts to manipulate UI of the page and if the user is already editing the page, our script can cause undesired behaviour.

We could either execute a different set of functions or at minimum, just not execute the script in design mode to keep the user experience clean.

Its relatively simply to detect the WebPart page design mode. Just add the following code to the startup your script.

In the next part of this series, I’ll talk about how we can detect if a Project Details Page is in Edit mode.



Fixing SharePoint designer 2013 workflow that won't switch to "Text-based designer" view

I recently wrote a big (200+ lines) List workflow in a SharePoint designer 2013. Those of you who have done it know that it becomes hard to maintain the workflow of this size as SPD is not really designed to author large workflows.

After spending few days, it become common for workflow designer to display validation errors every now and then which happened because SPD kept mysteriously deleting the variable references from the workflow actions.

Finally, i reached the stage where my workflow will not open in text-based designer mode, no matter what i do. It always opened in Visual designer mode with empty visio page.




Exporting the workflow as vsdx file and re-importing as new workflow didn't solve the problem.

After some experimentation, i was able to recover my workflow using the following procedure.

  1. I exported the original workflow as vsdx file using export to visio function. 
  2. I deleted the workflow from SharePoint designer
  3. In SharePoint designer, I created a new workflow “temp” and associated with my original SharePoint List.
  4. New workflow had only 1 line which was logging to history list. I published the workflow
  5. On my computer, I renamed the .vsdx file (step 1) to .zip and extracted all its contents.
  6. In SharePoint designer, I went to navigation windows on left hand side, there i clicked All Files -> WfSvc1 (this is a known folder where SPD stores workflow files)
  7. In that folder, there were many sub-folders, each having a guid as its name. each folder represents a workflow
  8. Went inside each folder and picked the folder which has most recent last modified date for workflow.xaml file (this represents workflow created in step 1)
  9. From the extracted folder (step 5) I copy pasted the file workflow.xaml to the SPD folder (step 8)
  10. Restarted SharePoint designer
  11. Opened the workflow designer page for the new workflow "temp" and it showed the restored workflow J
  12. Renamed & published the workflow

As a lesson learned, i decided to break the workflow into smaller manageable workflow pieces, so that the damage remains minimum in case of future corruption. 



How to clone a Project Detail Page

Project Detail pages are essentially ASPX files. But copying these pages isn't as simple as copying a document. If you copy these pages like an ordinary document, you'd notice that copied web part page doesn't retain any web parts in it. This is because Web parts information is stored in the SharePoint Content database. Use the following procedure to copy web part pages.

1) Go to Site Actions -> Manage Content and Structure
2) Go to the Project Detail Pages library
3) Select the PDP you want to copy
4) Click Actions -> Copy
5) Copy to any other document library or folder
6) Navigate to that document library or folder
7) Use the drop-down for that page and choose Edit Properties
8) Rename the page, update any other information, and click Save
9) Select the page, then click Actions -> Move
10) Choose the Project detail Pages folder
11) Then open the page and you should have an exact copy under the new page name



Query for getting lookup table in Row Number order

For your reporting needs, you may want to display values from a Lookup Table exactly in the order they are saved in PWA.

 

Within PWA, this setting is controlled using “Display order for lookup table” option on Edit Lookup Table Page.

 

Lookup

 

However, this sort order is not available in Reporting Database. Following query uses Published (and reporting) schema to get this information. This is tested on Project Server 2013 on premises.




Solution: Queue job "Project Workflow Check-in" stuck and then fail

Short answer: Restart the “Service Bus Gateway” and “Service Bus Message Broker” Service on the server where Workflow Manager is installed. The detailed description is below.

 

This has happened to me and a colleague so i thought that the solution is worth sharing.

 

On Project Server 2013 On premises instance, all my projects were stuck in “Project Workflow Check-in” queue job and that job was failing after about 45 minutes. The queue error message was,

 

General

  • Queue:
    • GeneralQueueJobFailed (26000) -WorkflowCheckinNotify.ProjectCheckinNotifyWorkflowMessage. Details: id='26000' name='GeneralQueueJobFailed' uid='b3f897eb-4695-e411-80cd-000d3ad00e15' JobUID='c7c8744b-4295-e411-80cd-000d3ad00e15' ComputerName='8fa7e1bd-09b4-4c64-b019-57c33d5c769c' GroupType='WorkflowCheckinNotify' MessageType='ProjectCheckinNotifyWorkflowMessage' MessageId='1' Stage='' CorrelationUID='1af0dc9c-9e05-a05e-c769-ca04319a2489'. For more details, check the ULS logs on machine 8fa7e1bd-09b4-4c64-b019-57c33d5c769c for entries with JobUID c7c8744b-4295-e411-80cd-000d3ad00e15.



Solution: Project returns to Project Site home page when you close it on PDP

One of the victims of Project Server 2013 utilising SharePoint platform is the navigation (in)consistency.

 

Here is a description of one of the associated issue (or feature by design, who knows?)

 

If you

i) Open a Project from Project Centre (Projects Page),

ii) Move between PDPs

iii) Press Close button on Ribbon

 

You’ll return on Projects page.

 

Showcase1

 

But if you,




How much can you over allocate a resource in resource plan?

I was giving Resource plan feature demo to a customer and out of curiosity, customer asked if I can assign 1,000 days of work to a resource on a single day. It turned out we couldn’t. When you press Save after assigning 1,000 days of work the system gave the following error.

 

“Your updates were not saved because of the following reasons: General error: Work value used is invalid. (Use this error information along with other errors to find out the cause of the problem.)”

Resource Plan

 

The behaviour was same for generic resources. And this raised the inevitable question from customer. “How much can I over allocate a resource on a given day in the resource plan?”