0
votes

Currently I am working on an AddIn for Microsoft Project 2010 Client. I would love to read out the value of a custom enterprisefield corresponding to the selected task, resource or project without using the PSI.

For example, I can simply read out the UID of a resource by

resource.GetField(MSProject.PjField.pjResourceGuid)

However I dont know how to read out the value of a Custom Enterprise field e.g. "MYCOMPANY_project_technicalSupervisor" which is based on a lookup table.

The next step would be to set the value for this field.

Can anybody help me?

1
Just small advise: try to minimise number of COM calls from .NET: cache everything you can, avoid chain calls: Application.Projects[0].Tasks[1] - this creates reference leaks and may slowdown your add-in several times, free links to COM entities using Marshal.ReleaseComObject; and one more advise about task.GetField/task.SetField - be very careful with fields of Work and Duration type - you may read e.g. hours as a number and write them into a field which expects days - users don't like that :)melan
Thank you. Unfortunatly I am not so firm in COM-Calls. Is there any Documentation about this topic, you can recommand. What is the alternative for calls like Application.Projects[0].Tasks[1] and why does this create memory leaks?user1781720
Maybe there is a documentation but I wasn't able to find it. The leaks are because you really initiate a reference to Projects collection, to single project from the collection, to tasks collection and to a single task from the collection. Correct way is to read projects collection into a variable, get a project from that collection and free reference to the collection if you no longer need it, and so on for other entities and collectionsmelan

1 Answers

1
votes

Ok even though I really looked around before I asked the question I found a solutoin:

task.GetField(ThisApplication.FieldNameToFieldConstant("MYCOMPANY_project_technicalSupervisor")) does the trick.