Ask a questionAsk a question
 

Answerhow to work with When Condition?

  • Thursday, October 29, 2009 12:26 PMA_R_K Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi there

    1- Is is possible to assign more than one vlaue in VALUE for WHEN?

    2- I want to set condition for WI in following order:

    If Product A selected in Product Field then set Allow and Suggested Value to GlobalList -> Component A
    If Product B selected in Product Field then set Allow and Suggested Value to GlobalList -> Component B
    Else set Alow and Suggested Value to GlobalList -> Components

    I made first and second step but I can not set the else condition to see correct behavior...

    Any Idea?


    <FieldReference refname="System.Common.Component">
      <WHEN field="System.Common.Product" value="Product A">
        <ALLOWEDVALUES>
          <GLOBALLIST name="Component A" />
        </ALLOWEDVALUES>
        <SUGGESTEDVALUES>
          <GLOBALLIST name="Component A" />
        </SUGGESTEDVALUES>
      </WHEN>
      <WHEN field="System.Common.Product" value="Product B">
        <SUGGESTEDVALUES>
          <GLOBALLIST name="Component B" />
        </SUGGESTEDVALUES>
        <ALLOWEDVALUES>
          <GLOBALLIST name="Component B" />
        </ALLOWEDVALUES>
      </WHEN>
    </FieldReference>
    

Answers

  • Thursday, November 05, 2009 10:17 AMHongye SunMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    That's correct. This is because when you select Product A, TFS will select the items which are both inside list Component A and Components. However, there is no one duplicate so the list shows empty. The same as Product B.

    When you select other product, TFS will only use Components list.

    I am sorry that we have no workaround for this issue right now. The only wayis to specify all the Products in the WHEN condition. 

    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Thursday, October 29, 2009 4:42 PMGregg Boer - TFS Product TeamMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm thinking the ELSE condition can be handed by defining that ALLOWEDVALUES rule outside of a WHEN clause. Then the ALLOWVALUES stays set to Globallist->Components, unless a WHEN clause takes over.
    Team Foundation Server
  • Friday, October 30, 2009 4:59 AMA_R_K Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    Hi Gregg 

    Thank you for Replay

    Actually I did as you suggest at first, The problem is that SUGGESTEDVALUES is working as expected, but after I add ALLOWVALUES just Else condition works.  
    No Matter what I do ALLOWVALUES does not works.

    Any Idea?

    <FieldReference refname="Querix.Common.Component">
      <WHEN field="Querix.Common.Product" value="Product A">
        <ALLOWEDVALUES>
          <GLOBALLIST name="Component A" />
        </ALLOWEDVALUES>
        <SUGGESTEDVALUES>
          <GLOBALLIST name="Component A" />
        </SUGGESTEDVALUES>
      </WHEN>
      <WHEN field="Querix.Common.Product" value="Product B">
        <SUGGESTEDVALUES>
          <GLOBALLIST name="Component B" />
        </SUGGESTEDVALUES>
        <ALLOWEDVALUES>
          <GLOBALLIST name="Component B" />
        </ALLOWEDVALUES>
      </WHEN>
      <SUGGESTEDVALUES>
        <GLOBALLIST name="Components" />
      </SUGGESTEDVALUES>
      <ALLOWEDVALUES>
        <GLOBALLIST name="Components" />
      </ALLOWEDVALUES>
    </FieldReference>
    
  • Friday, October 30, 2009 7:50 AMHongye SunMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Maybe I am wrong. I don't think this can work.

    The logic in your sample code is when select Product A, Allowed and Suggested items are items which are in both global list Component A and Components. This is an AND logic I think.

    The only way I can think of is to specify all the Products in the WHEN condition. 

    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Friday, October 30, 2009 9:29 AMA_R_K Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    In My Example When I select Product A or Product B, the component field shows empty list. But for other products i see list of Components.

  • Thursday, November 05, 2009 10:17 AMHongye SunMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    That's correct. This is because when you select Product A, TFS will select the items which are both inside list Component A and Components. However, there is no one duplicate so the list shows empty. The same as Product B.

    When you select other product, TFS will only use Components list.

    I am sorry that we have no workaround for this issue right now. The only wayis to specify all the Products in the WHEN condition. 

    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.