I'm working on a function where I will need to access fields of the resource assignments on a given task. Assignments can have their own values in fields and can be set in the Task Usage View of MS Project.
I need to set values on fields of the assigments. Task objects have a SetField method but Assigment objects do not, is there any equivalent way to call SetField but for an assigment object? I could write a big switch statement that can receive the Field Constant as a argument like this:
My problem with that is the PjField Enum does not actually cover all of the possible fields, and in particular, it does not have many Enterprise Fields called out in the Enum. For example, 188776472 is the FieldID of an Enterprise Field in a project I'm testing on, yet it's nowhere to be found in the Enum.
This can be done using the SetField method of the application object with the caveat that it works on whatever is active (selected). For example, to set an Enterprise field, "Program Manager", for the active assignment in the Task Usage view:
SetField "Program Manager", "Kenny"
The trick will be to activate the correct row in the Task Usage view. Try something like this where instead of the FieldID, you use the field name:
ViewApply "Task Usage"
Find "UniqueID", "equals", a.Task.UniqueID
Find "Name", "equals", a.Resource.Name
SetField FieldName, Value
Of course, add code to validate you've found the correct row, return to previously active view, etc., and adapt to c#.