none
Adding custom indicator to sub-projects RRS feed

  • Question

  • I have a Project 2010 Add-In using VSTO and C#. I am defining a custom indicator based on a value being present in the Text30 field of a task. This works as expected when I have only one project, however when I have a project with sub-projects the custom indicator is not set on the Sub-Projects only on the master my code is below. What am I doing wrong? Is what I want to do even possible? Thanks in advance.

     

                Application.CustomFieldIndicators(
                    FieldID: PjCustomField.pjCustomTaskText30, 
                    SummaryInheritsNonsummary: true, 
                    ProjectInheritsSummary: true, 
                    ShowToolTips: true);
                // The custom  indicator 
                Application.CustomFieldIndicatorAdd(
                    FieldID: PjCustomField.pjCustomTaskText30,
                    Test: PjComparison.pjCompareContains,
                    Value: indicatorValue,
                    IndicatorID: value,
                    CriteriaList: PjCriteriaList.pjCriteriaNonSummary,
                    Index: 1
                    );
                Application.CustomFieldPropertiesEx(
                    FieldID:PjCustomField.pjCustomTaskText30, 
                    Attribute: PjCustomFieldAttribute.pjFieldAttributeNone, 
                    SummaryCalc: PjSummaryCalc.pjCalcNone, 
                    GraphicalIndicators:true, 
                    AutomaticallyRolldownToAssn:false);
    


    Thursday, November 3, 2011 8:41 PM

Answers

  • Thomas,

    I don't use VSTO or C# but I think I can help using some VBA experience. At first I had trouble getting the CustomFieldIndicatorAdd Method to work at all (my first time with that method), but I think I've got a path for you to pursue.

    Even though the method applies to the application object there is apparently a caveat when working with a master/subproject structure. Normally I would have said to address the SourceProject attributes of the specific subproject but that doesn't apply in this case. The answer to your basic question is, you are doing nothing wrong but a little understanding about the Project's master/subproject structure may be in order.

    Even though you can see subproject fields at the master level you are not actually looking at the subproject fields. Hence if you attempt to customize Text30 for example, at the master level, you are only customizing it for tasks that actually belong to the master, not for tasks belonging to subprojects. You must specifically customize that field at the subproject level also. So how do you use this information in your case? First run your code to set the new indicator criteria at the master level. Then use the organizer (i.e. OrganizerMoveItem Method) to move the updated Text30 custom indicator to each of the subprojects. Either that or run your code separately on each of your subprojects in addition to the master. I think the first approach is quicker and more efficient.

    Hope this helps.

    John

    • Marked as answer by Thomas_Bell Friday, November 4, 2011 2:55 PM
    Friday, November 4, 2011 3:49 AM

All replies

  • Thomas,

    I don't use VSTO or C# but I think I can help using some VBA experience. At first I had trouble getting the CustomFieldIndicatorAdd Method to work at all (my first time with that method), but I think I've got a path for you to pursue.

    Even though the method applies to the application object there is apparently a caveat when working with a master/subproject structure. Normally I would have said to address the SourceProject attributes of the specific subproject but that doesn't apply in this case. The answer to your basic question is, you are doing nothing wrong but a little understanding about the Project's master/subproject structure may be in order.

    Even though you can see subproject fields at the master level you are not actually looking at the subproject fields. Hence if you attempt to customize Text30 for example, at the master level, you are only customizing it for tasks that actually belong to the master, not for tasks belonging to subprojects. You must specifically customize that field at the subproject level also. So how do you use this information in your case? First run your code to set the new indicator criteria at the master level. Then use the organizer (i.e. OrganizerMoveItem Method) to move the updated Text30 custom indicator to each of the subprojects. Either that or run your code separately on each of your subprojects in addition to the master. I think the first approach is quicker and more efficient.

    Hope this helps.

    John

    • Marked as answer by Thomas_Bell Friday, November 4, 2011 2:55 PM
    Friday, November 4, 2011 3:49 AM
  • John,

     

    Thanks so much for taking the time to offer an answer to my question, it does look like this may be the right approach. I am a little unsure, however, how I would use the OrganizerMoveItem Method (as usual there is a dearth of documentation). Do you have any code samples that you could provide? 

     

    Thanks in advance. 

    Thomas

    Friday, November 4, 2011 2:03 PM
  • I figured it out thanks so much for answering my question.
    Friday, November 4, 2011 2:55 PM
  • Thomas,

    You're welcome and thanks for the feedback.

    Just for reference I make full use of the object browser for VBA syntax. Unfortunately, the object browser information is less helpful in the later versions of Project, (i.e. 2007 &2010), than it was in previous versions but it is still the best source. I don't know what is available via Visual Studio but I assume it has a path to the application's object model.

    John

     

    Friday, November 4, 2011 3:38 PM
  • John,

    I do have a follow up question that maybe you, or anyone else, could shed some light on.  Currently when I use the OrganizerMoveItem method Project prompts me asking if I would copy over the graphical indicator.  I would like to be able to prevent this. Is there some way to get full write permissions to the source project on the sub, or some other method to prevent this prompting?

    Thomas

    Tuesday, November 22, 2011 9:04 PM