none
Project Server PSI - Insert or update RRS feed

  • Question

  • Hi

    I have observed that project server behaves differently at the time of insert and update. during PSI call I was using the QueueUpdateProject Method to update the certain custom Field, But it does not affect untill there is already a row then and them update method is effective.

    My Question is how to identify that Custom field A needs to insert and Custom Field B needs to update. and set the project dataset in order to take effect the new changes made into the project.

    any suggestion???


    Thanks, Parth

    Monday, March 18, 2013 12:32 PM

Answers

  • private static void SetCustomFields(ref SvcProject.ProjectDataSet _projDS, Guid _CustomFieldGuid, Guid _LookUpGuid, Guid _projUid) { bool foundCF = false; for (int x = 0; x < _projDS.ProjectCustomFields.Count; x++) { var customfield = _projDS.ProjectCustomFields[x]; if (_CustomFieldGuid == customfield.MD_PROP_UID) { customfield.CODE_VALUE = _LookUpGuid; foundCF = true; break; } } if (!foundCF) { //need to add a custom field row into the project dataset as a value has not been set previously SvcProject.ProjectDataSet.ProjectCustomFieldsRow cfRow = _projDS.ProjectCustomFields.NewProjectCustomFieldsRow(); cfRow.PROJ_UID = _projUid; cfRow.CUSTOM_FIELD_UID = Guid.NewGuid(); cfRow.MD_PROP_UID = _CustomFieldGuid; cfRow.CODE_VALUE = _LookUpGuid; _projDS.ProjectCustomFields.AddProjectCustomFieldsRow(cfRow); } }

    Code snippet of what I do - try to find the custom field, and if it doesn't exist then create it.
    • Marked as answer by Parth Rawal Thursday, March 21, 2013 6:29 AM
    Thursday, March 21, 2013 6:14 AM

All replies

  • private static void SetCustomFields(ref SvcProject.ProjectDataSet _projDS, Guid _CustomFieldGuid, Guid _LookUpGuid, Guid _projUid) { bool foundCF = false; for (int x = 0; x < _projDS.ProjectCustomFields.Count; x++) { var customfield = _projDS.ProjectCustomFields[x]; if (_CustomFieldGuid == customfield.MD_PROP_UID) { customfield.CODE_VALUE = _LookUpGuid; foundCF = true; break; } } if (!foundCF) { //need to add a custom field row into the project dataset as a value has not been set previously SvcProject.ProjectDataSet.ProjectCustomFieldsRow cfRow = _projDS.ProjectCustomFields.NewProjectCustomFieldsRow(); cfRow.PROJ_UID = _projUid; cfRow.CUSTOM_FIELD_UID = Guid.NewGuid(); cfRow.MD_PROP_UID = _CustomFieldGuid; cfRow.CODE_VALUE = _LookUpGuid; _projDS.ProjectCustomFields.AddProjectCustomFieldsRow(cfRow); } }

    Code snippet of what I do - try to find the custom field, and if it doesn't exist then create it.
    • Marked as answer by Parth Rawal Thursday, March 21, 2013 6:29 AM
    Thursday, March 21, 2013 6:14 AM
  • Great!! Doing the same thing. 

    But was wondering is there anything out of the box available which takes care of the same. as checking and then updating will take some time.

    In here AcceptChanges() will help???


    Thanks, Parth

    Thursday, March 21, 2013 6:29 AM
  • My understanding is AcceptChanges works on the row, so you'd still need to check for the row to exist first, and get it or create it. Nothing out of the box that I know of
    Thursday, March 21, 2013 6:52 AM