none
PS2013 - Custom Field value via Javascript RRS feed

  • Question

  • Hi all,

    Could anyone provide a valid example about how to get custom fields value within the javascript library of Project Server?

    Thanks!

    Friday, April 26, 2013 9:50 PM

All replies

  • Look in the free Project SDK from MSDN for PSI examples.

    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    Friday, April 26, 2013 11:54 PM
    Moderator
  • Hi Ron,

    I have already installed the Project SDK, and which example do you mean? Every example in this SDK "play" with project fields as Name, Description, StartDate and so on like this:

    projContext.load(projects, 'Include(Name, Description, StartDate, Id)');

    After this call you can get the values via the OOB methods:

      row.insertCell().innerText = project.get_name();
                    row.insertCell().innerText = project.get_description();
                    row.insertCell().innerText = project.get_startDate();
                    row.insertCell().innerText = project.get_id();

    But what I want is to get Custom Fields values. Do you have a valid example?

    I will be very glad to have one...

    Thanks!

    Saturday, April 27, 2013 7:31 AM
  • I am having this same issue. I have tried using the get_fieldValues method, get_customFields method, and even including the GUID for the custom field, but it always returns a value of null for my custom field even when there is definitely a value and project is checked in.

    EDIT:

    I just found how to retrieve it from this post: social.msdn.microsoft.com/Forums/en-US/d79f22f2-7fd2-46af-b778-e189c8611120/use-csom-to-update-projects-custom-fields (sorry, it says I can't link it until my account is verified)

    First, in PWA settings, go to the page to edit that field and expand the section at the very bottom of the page. That will give you the custom field's GUID.

    Then, when you load your projects through CSOM, you would include that field like Custom_<<guid of custom field>>. Example:

    projContext.load(projects, 'Include(Name, Id, Custom_5a44a4e6-f9ee-e211-bea4-abaed6b08d31)');

    Then in your querySuccess function, when you enumerate through your projects, like where they call "project.get_id()", you would say

    project.get_item('Custom_5a44a4e6-f9ee-e211-bea4-abaed6b08d31')

    It will return the value. This worked for me, at least.

    • Edited by jebbbbzzz Thursday, August 1, 2013 10:25 PM found solution
    • Proposed as answer by jebbbbzzz Thursday, August 1, 2013 10:25 PM
    Thursday, August 1, 2013 9:49 PM