4

I uploaded a javascript with a web part to my Project Server 2013 environment, and included the web part in one of the project's PDP, which contains the following code:

var $puidElement = $("[GUID='" + ProjectUniqueGUID + "']");
    if ($puidElement.is("input"))

Would this return true if the project is edit mode? If not, how can I detect that the project is in Edit mode using JavaScript?

2 Answers 2

2

The correct way to check if the project is checked out is to use project.isCheckedOut() (MSDN reference for JavaScript).

The C# documentation shows that it returns a bool. The method exists for JavaScript as well, but it doesn't show the return value, but it should be a bool.

1

Every custom field has a GUID, and when the project is in edit mode, you'll see that field as an input box, so we really just need to select that element and check if it's of the type "input". Here's a step by step solution:

  1. First you need to create a project custom field, or just reuse any existing (preferably one that already exists in the PDP where you'll add the script)
  2. Then on the created/choosen custom field page, expand "System Identification Data" and write down the GUID for that field
  3. If the field is not added to the PDP already, add it

Add the following script to the page, and pass the field GUID to the function.

function IsProjectInEditMode(ProjectCFGUID) {
  var $cfInput = $("[GUID='" + ProjectCFGUID + "']");
  return $cfInput !== undefined && $cfInput.is("input");
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.