Skip to main content

Search

if condition for calculating or changing value

Comments

5 comments

  • ArdeviaForum

    Original Post by dany (Imported from Ardevia Forum)

    Not quite sure I understand exactly, but the way I understand the easiest option for you is to add some validation to the choice fields:
    1. Select your choice field
    2. Open Expression Builder for 'Validation' control
    3. Now define some condition expression that must be met for the selection to be valid. Example: ([[ChoiceField1]] == "Cars") && (([[ChoiceField2]] != "Mercedes") || ([[ChoiceField2]] != "Volvo"))
    4. Set the "Validation Text" with the error message you want to have shown when validation is not successful

     

    Alternatively you could try an approach similar to the solution posted here

    0
  • ArdeviaForum

    Original Post by MKO (Imported from Ardevia Forum)

    I am sorry

     

    -I can get it why i need to put condition in 'Visible' control?
    -And why is that code.
    -I have 3 fields that have same drop down. And I want when the first is chosen "Mercedes" then i can not chose Mercedes in others, or to be some message or error.

     

    Thank you!

    0
  • ArdeviaForum

    Original Post by dany (Imported from Ardevia Forum)

    Sorry, my mistake, should have been 'Validation' control. Have corrected in in post above.
    The code (expression) allows you to define the rule for the validation. In your case you would want a validation expression on the Choice2 field like this:
    ([[Choice2]] != [[Choice1]]) && ([[Choice2]] != [[Choice3]])
    This will make the error message defined in Validation Text be shown when the user tries to save with Choice2 set the same value as Choice1 or Choice3.

    0
  • ArdeviaForum

    Original Post by iryna (Imported from Ardevia Forum)

    Solution for the following case with drodowns:
    There are 3 fields with the same dropdown menu.
    There should be no possibility for the second dropdown to select the option that is already selected in the first dropdown. 
    And there should be no possibility for the third dropdown to select the option that is already selected in the first or second dropdowns.

     

    1. Select your second/third dropdown field
    2. Open Expression Builder for 'Initial'/'Calculated' control (the same expression for both controls)
    3. Select 'Function code'
    4. Insert the following code example and replace list names with your values

     

    'Initial' and 'Calculated' expression for the second dropdown:

     

    Code:

     var selectedOption = [[Dropdown1]];    
    if (selectedOption){    
      setTimeout(function(){      
        jQuery('span[fieldname=Dropdown2] option[value="'+selectedOption+'"]').remove();
      },100); 
     } 
    var selectedValue = Ardevia.Expressions.Core.FieldValueProvider.GetFormFieldValue('Dropdown2'); 
    return selectedValue == selectedOption ? null:selectedValue;
    

     

    'Initial' and 'Calculated' expression for the third dropdown:

     

     

    var selectedOption = [[Dropdown1]];
    var selectedOption1 = [[Dropdown2]]; 
    if ([[Dropdown1]]){    
    
      setTimeout(function(){      
        jQuery('span[fieldname=Dropdown3] option[value="'+selectedOption+'"]').remove();
      },100); 
     } 
     if ([[Dropdown2]]){    
    
      setTimeout(function(){      
        jQuery('span[fieldname=Dropdown3] option[value="'+selectedOption1+'"]').remove();
      },50); 
     } 
    var selectedValue = Ardevia.Expressions.Core.FieldValueProvider.GetFormFieldValue('Dropdown3'); 
    return selectedOption==selectedValue || selectedOption1==selectedValue?null:selectedValue; 
    

     

    Hope this answers your question.

    0
  • ArdeviaForum

    Original Post by MKO (Imported from Ardevia Forum)

    Thank you very much!

    0

Please sign in to leave a comment.