none
set Custom Field on assignment RRS feed

  • Question

  • i have a custom field thats not getting populated on task update even after the custom field being set to roll-down, so as a work around i thought i will write a vba macro to set the custom field in the assignment.

    How can i set the customfield using vba.? my custom field name is "Work Reference" with a space in the name. I know if the customfield doesnot have a space i can use a.customfieldname where a is assignment. 

    however i need to stay with the space in the name? Any suggestions?

    thanks 


    Simi
    Monday, July 25, 2011 12:06 PM

Answers

  • Hi, I am told that this fieldnametofieldconstant does not work for assignment custom fields, that there you can use assignmentobject.customfieldname but that indeed the custom field name cannot have blanks.

    Greetings,

    • Marked as answer by Simi Varghese Wednesday, July 27, 2011 6:50 AM
    Tuesday, July 26, 2011 9:42 AM
    Moderator

All replies

  • Simi,

    It would be helpful to know which version of Project you are using.

    When you say the custom field value does not flow down to the assignment row are you sure you haven't manually tried to enter a value in the custom field for the assignment row? If you have, even one time while experimenting around, that action will effectively lock out that automatic roll down functionality. You will need to clear the custom field (i.e. use the Delete button in the custom field window), then re-customize the field again.

    A second point is that there is no "customfieldname" property. There is a "customfieldgetname" property but it only applies to the application object, not to a task, resource or assignment object. Further, if you were trying to set the value for an assignment custom field, you do not need the custom name of that field. The following VBA code snippet will do what you want. Note: this abbreviated loop only works on the first resource and it assumes the custom field, (which may have been renamed as "work reference"), is Text1.

    Sub customfield()

    For Each a In ActiveProject.Resources(1).Assignments

        a.Text1 = "whatever"

    Next a

    End Sub

    John

    Monday, July 25, 2011 3:00 PM
  • I am using PS 2010 and the custom field is an enterprise custom field and not a local custom field.

    what i am doing is I create a task by entering all the details including the CF "work reference" to the project , save and publish.when i look up the value in the task usage view, the value do show up. however when i go to the time sheet i am not see the value for the work reference.  Is there some sort of a patch or sp1 i need to install on the server.

    for the custimefielname as a property and it did work(without a space) however with a space i am get an error.

     

    thanks 

     

     

     

     


    Simi
    Tuesday, July 26, 2011 6:06 AM
  • did you try this:

    Sub test()
    
    ActiveProject.Tasks(1).SetField (FieldNameToFieldConstant("<Custom FieldName>")), "<Your Value as String>"
    
    End Sub
    



    Thanks, Parth
    Tuesday, July 26, 2011 9:25 AM
  • Hi, I am told that this fieldnametofieldconstant does not work for assignment custom fields, that there you can use assignmentobject.customfieldname but that indeed the custom field name cannot have blanks.

    Greetings,

    • Marked as answer by Simi Varghese Wednesday, July 27, 2011 6:50 AM
    Tuesday, July 26, 2011 9:42 AM
    Moderator
  • Initially i thought that they want to update the Task Level custom Field.. (i have a custom field thats not getting populated on task update)... 

    Sorry, may be i have interpreted wrongly...


    Thanks, Parth
    Tuesday, July 26, 2011 9:52 AM
  • Thanks Jan.. I guess i have to change my custom field :(
    Simi
    Wednesday, July 27, 2011 6:50 AM