Answered by:
CSOM - Read Project Custom Field (Lookup) Value

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
- Edited by Woon Woon, Gan Wednesday, August 14, 2013 8:18 AM
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.
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, GanMonday, August 19, 2013 2:29 AM -
Use a combination of this, which is for task level easier to do Project level, http://social.msdn.microsoft.com/Forums/en-US/d79f22f2-7fd2-46af-b778-e189c8611120/use-csom-to-update-projects-custom-fields and the Project 2013 SDK Documentation http://msdn.microsoft.com/en-us/library/office/jj163064.aspxMonday, 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, GanThursday, 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.
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, GanThursday, December 26, 2013 9:20 AM