locked
CSOM - Read Project Custom Field (Lookup) Value RRS feed

  • Question

  • Dear All,

    How do I read the project custom field (lookup) values using CSOM. My code as follows:

    projContext.Load(projContext.Projects);
    projectContext.ExecuteQuery();
    foreach (PublishedProjectpubProj in projContext.Projects)
    {
        projContext.Load(pubProj.CustomFields);
        projContext.ExecuteQuery();
        foreach (CustomFieldcf in pubProj.CustomFields)
        {
            string intname = cf.InterName.ToString();
            string cf_value = pubProj[intname].ToString();  // threw an exception here
    ....

    My guess is I am missing some steps in order to obtain the lookup value information.

    Thanks,
    Woon Woon, Gan




    Wednesday, August 14, 2013 8:17 AM

Answers

  • Actually, as far as I know PSI does not work with the O365. I tried it also but some how could not make it work. instead i used the CSOM to read the lookup table value.

    Here is the link to my blog where i have mentioned how to do it using CSOM.

    Project Lookup

    PS: When you use the Project to read the related custom field, use the Draft project and While you check out the project, please include the CustomField.


    Thanks, Parth

    • Proposed as answer by Parth Rawal Thursday, December 26, 2013 9:07 AM
    • Marked as answer by Woon Woon, Gan Thursday, December 26, 2013 9:22 AM
    Thursday, December 26, 2013 9:07 AM

All replies

  • spelling mistake

    string intname = cf.InterName.ToString();

    string intname = cf.InternalName.ToString();

    Friday, August 16, 2013 3:31 PM
  • Hi,

    Nice catch but this is just a typo error when I submit to the forum. I could obtain the intname but could not obtain the project custom field value. I have since use PSI to obtain the project custom field value but would really want to find out how to do so using CSOM.

    Regards
    Woon Woon, Gan

    Monday, August 19, 2013 2:29 AM
  • Monday, August 19, 2013 4:58 PM
  • did you find the answer for the same!?

    Thanks, Parth

    Tuesday, December 24, 2013 12:07 PM
  • Hi Parth, I used PSI to read the project custom field lookup value instead. Regards, Woon Woon, Gan
    Thursday, December 26, 2013 1:58 AM
  • Actually, as far as I know PSI does not work with the O365. I tried it also but some how could not make it work. instead i used the CSOM to read the lookup table value.

    Here is the link to my blog where i have mentioned how to do it using CSOM.

    Project Lookup

    PS: When you use the Project to read the related custom field, use the Draft project and While you check out the project, please include the CustomField.


    Thanks, Parth

    • Proposed as answer by Parth Rawal Thursday, December 26, 2013 9:07 AM
    • Marked as answer by Woon Woon, Gan Thursday, December 26, 2013 9:22 AM
    Thursday, December 26, 2013 9:07 AM
  • Hi Parth,

    For me, PSI is fine as I use it for on-premise project server, it is useful to know how to do it using CSOM for Project Online.  Thanks for sharing the information.

    Regards,
    Woon Woon, Gan

    Thursday, December 26, 2013 9:20 AM