PSI new task custom fields are not being written (PS2007) RRS feed

  • Question

  • Hello,

    I am developing a process throught PSI that adds a new task into a existing project. For this purpose, first, via PWA, I have created 4 new task custom fields (one numeric, two dates and one text) I need to inform when I create the task. I also have to write 2 numeric task custom fields that already existed.

    The task is being created correctly and the two custom fields that existed before are also being written correctly. But, any of the new 4 new custom fields are being written. How can I solve this?

    This is the code:

    WSProject.Project project = InitProject();
    WSProject.ProjectDataSet dsProject = new WSProject.ProjectDataSet();
    Guid taskGuid = CreateTaskRow(dsProject, projectGuid, taskname, duration, startdate);
    Guid assignmentGuid = CreateAssignmentRow(dsProject, projectGuid, taskGuid, resGuid);
    //Custom Fields
    Guid idNCF1 = GetGuidUsingFieldName("NCF1"); //OLD
    Guid idNCF2 = GetGuidUsingFieldName("NCF2"); //OLD
    Guid idNCF3 = GetGuidUsingFieldName("NCF3"); //NEW
    Guid idDCF1 = GetGuidUsingFieldName("DCF1"); //NEW
    Guid idDCF2 = GetGuidUsingFieldName("DCF2"); //NEW
    Guid idTCF1 = GetGuidUsingFieldName("TCF1"); //NEW
    SetNumberCustomField(dsProject, projectGuid, taskGuid, idNCF3, 4); //Not Works
    SetDateCustomField(dsProject, projectGuid, taskGuid, idDCF1, DateTime.Today); //Not Works
    SetTextCustomField(dsProject, projectGuid, taskGuid, idTCF1, "A"); //Not Works
    SetDateCustomField(dsProject, projectGuid, taskGuid, idDCF2, DateTime.Today); //Not Works
    SetNumberCustomField(dsProject, projectGuid, taskGuid, idNCF1, 1); //Works
    SetNumberCustomField(dsProject, projectGuid, taskGuid, idNCF2, 2); //Works
    //Using debug, here I can see that all custom fields are properly set in dsProject TaskCustomFields table
    Guid jobId = Guid.NewGuid();
    project.QueueAddToProject(jobId, sessionId, dsProject, false);

    SetNumberCustomField (I omitted data and text functions because essentially are the same)

    private static void SetNumberCustomField(WSProject.ProjectDataSet dsProject,
                                       Guid projectId,
                                       Guid taskId,
                                       Guid customFieldId,
                                       int CFValue)
                WSProject.ProjectDataSet.TaskCustomFieldsRow tCustomField = dsProject.TaskCustomFields.NewTaskCustomFieldsRow();
                tCustomField.CUSTOM_FIELD_UID = Guid.NewGuid();
                tCustomField.PROJ_UID = projectId;
                tCustomField.TASK_UID = taskId;
                tCustomField.FIELD_TYPE_ENUM = (byte)PSLibrary.CustomField.Type.NUMBER;
                tCustomField.NUM_VALUE = CFValue;
                tCustomField.MD_PROP_UID = customFieldId;

    Friday, May 18, 2012 10:14 AM

All replies

  • Hi There--

    Seems to be missing M in tCustomField.NUM_VALUE = CFValue;  (Numbers are decimal - the M suffix is used as this value would normally default to double
    They are entered against NUM_VALUE).

    Please see the sample from Brian's article & see if something is missed.

    // First a text field not based on a lookup table
                    WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRowTaskText =
                    cfRowTaskText.PROJ_UID = projectGuid;
                    // For our Task CF rows we need the Task UID as well as the Project UID
                    cfRowTaskText.TASK_UID = taskGuid;
                    cfRowTaskText.CUSTOM_FIELD_UID = Guid.NewGuid();
                    cfRowTaskText.MD_PROP_UID = taskTextGuid;
                    // As we have no lookup table for this text field the value goes in TEXT_VALUE
                    cfRowTaskText.TEXT_VALUE = "My Text Value";
    // Next a Number field
                    WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRowTaskNumber =
                    cfRowTaskNumber.PROJ_UID = projectGuid;
                    cfRowTaskNumber.TASK_UID = taskGuid;
                    cfRowTaskNumber.CUSTOM_FIELD_UID = Guid.NewGuid();
                    cfRowTaskNumber.MD_PROP_UID = taskNumberGuid;
                    // Numbers are decimal - the M suffix is used as this value would normally default to double
                    // They are entered against NUM_VALUE
                    cfRowTaskNumber.NUM_VALUE = 25.6M;
    Hope that helps.

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog:

    Friday, May 18, 2012 10:39 AM
  • Hi Amit,

    I've tested it and the same is happening with number fields. This doesn't seem to solve my problem. The M is not being set in the old fields and they are being written and it will not solve Date and Text fields. 

    Thank you anyway, I appreciate the answer.

    Friday, May 18, 2012 11:18 AM
  • Hi Pau,

    I am sorry if it didn't help you. Let me see my code which works with the similar way. I'll post my sample code in some time.

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog:

    Friday, May 18, 2012 12:14 PM
  • Not sure if I am missing something Pau, but you shouldn't need to set the tCustomField.FIELD_TYPE_ENUM = (byte)PSLibrary.CustomField.Type.NUMBER; within your code as it will already be defined as part of the custom field, that you have already created and identified by the MD_PROP_UID.  However I don't know if this would be breaking anything.  Also not sure what you mean by OLD and NEW.  All fields that you are using must already exist - you cannot create on the fly just by adding to a task - in that respect they should all be 'old'.

    Best regards,


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page

    Tuesday, May 22, 2012 10:47 PM