none
CSOM - update resource default and custom fields RRS feed

  • Question

  • can someone point me to an example of how to update resource default and custom fields by using CSOM?

    tatiana


    Monday, December 14, 2015 9:12 PM

Answers

  • Hi,

      See if this helps

    https://projectservercodesnippets.wordpress.com/2015/08/03/set-a-resource-custom-field-using-csom/

    Regards,

    Faizan.


    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    • Marked as answer by tatiana obrien Tuesday, December 15, 2015 2:44 PM
    Tuesday, December 15, 2015 4:51 AM
  • i just tried the link and it didn't work for me either :( its a really good blog . i hope its gets back online.

    here is the example of how to update custom field (still don't know how to create a new row for custom field though)

    CustomFieldCollection customFields = projContext.CustomFields;
    EnterpriseResourceCollection resources = projContext.EnterpriseResources;

    projContext.Load(projContext.EnterpriseResources.GetByGuid(rs.Id));
    projContext.ExecuteQuery();

    projContext.Load(rs);
    projContext.Load(rs.CustomFields);

    projContext.ExecuteQuery();

    CustomField cfPersonType;

    String cfPersonTypeInternalName;

    cfPersonType = customFields.First(c => c.Name == "Resource_HR_Person_Type");
    cfPersonTypeInternalName = cfPersonType.InternalName;

    rs[cfPersonTypeInternalName] = "Custom Field Value Here";

      resources.Update();
    projContext.ExecuteQuery();



    tatiana


    Friday, December 18, 2015 4:19 PM

All replies

  • Hi,

      See if this helps

    https://projectservercodesnippets.wordpress.com/2015/08/03/set-a-resource-custom-field-using-csom/

    Regards,

    Faizan.


    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    • Marked as answer by tatiana obrien Tuesday, December 15, 2015 2:44 PM
    Tuesday, December 15, 2015 4:51 AM
  • Syed, the link you posted does not work. It requires some kind of sign in?

    Friday, December 18, 2015 3:58 PM
  • i just tried the link and it didn't work for me either :( its a really good blog . i hope its gets back online.

    here is the example of how to update custom field (still don't know how to create a new row for custom field though)

    CustomFieldCollection customFields = projContext.CustomFields;
    EnterpriseResourceCollection resources = projContext.EnterpriseResources;

    projContext.Load(projContext.EnterpriseResources.GetByGuid(rs.Id));
    projContext.ExecuteQuery();

    projContext.Load(rs);
    projContext.Load(rs.CustomFields);

    projContext.ExecuteQuery();

    CustomField cfPersonType;

    String cfPersonTypeInternalName;

    cfPersonType = customFields.First(c => c.Name == "Resource_HR_Person_Type");
    cfPersonTypeInternalName = cfPersonType.InternalName;

    rs[cfPersonTypeInternalName] = "Custom Field Value Here";

      resources.Update();
    projContext.ExecuteQuery();



    tatiana


    Friday, December 18, 2015 4:19 PM