Skip to main content

Hi,

 

I am wondering if the following scanrio is expected behavoir or I am missing something in the way I am applying rules to controls on a smartform (K2 5.3).

 

Scenario.

 

1) I have a dropdown choice control which I will set a rule on to change another controls value dependant on the selection value of the dropdown control.

 

In the form initialize rule, there is a rule to populate this control with dropdown data and that seems to be forcing the rule on my control to run at the same time as the form loads (ie: not giving me a chance to select a value).

 

As a workaround I have to put a fake control on the form (transfer data to it at the end of the form load rules, and then use this as an additional condition when running the rule 'on change' (ie: if 'fake field is not empty').

 

This doesnt seem a very elegant way of doing it, does anyone else have this issue or is it normal?

 

Thanks, Julie

Hi Julie,


 


It sounds like when the dropdown is populating on initialization, the rule is detecting that as a change, which I would guess is likely expected behavior. I would suggest adding a "If the form/view passes validation" condition to your "When the dropdown is changed" rule to validate if a value has actually been selected by checking "Required". This should prevent anything from passing onto the second dropdown while avoiding the need for a secondary control.



Cheers,


Emily


Hi Emily,

 

Yes, that's what I suspected also is happening and I have put in my own workaround but I wouldn't have thought that this was expected behavoir as there is no way around stopping a control being populated with data on form initialisation and thought K2 smartforms would recognise the difference between a form load rule and an actual physical change on a control on the form thereafter?

The manual fix is messy (I have done it differently but at least it is defined as a manual fix and not mis-construed as an essential rule for someone in the future looking at the code).  It reminds me of when SharePoint workflow used to consider an update on a new item form to be considered an edit also and fire the edit workflow! ... They overcame this in future versions.

 

I just want to be absolutely sure that K2 haven't overcome this also and I am not missing something?


Hi Julie,


 


Depending on how the form loads, certain controls may not have data initially loaded in. In terms of how K2 sees the form, there is no difference between loading data in a control via the initialize data load, if a user manually enters the data, or if another rule populates the control with data. This is to allow the developer the freedom to fully use this functionality, which can be modifed to the exact desired behavior through additional rules. 


 


In our case, what I believe would be easiest would be to add a "If control contains a value" condition before the condition that is checking if the control was changed. This will cause the check to only happen when the control already has a value, and block it from happening on the initial load as the control does not contain a value yet.


 


Thanks,


Thomas


 


K2 will not accept any liability for any issues arising from actions taken in respect of the information provided by any forum member


Thanks Emily and Thomas for the clarification :-)

 

I'll apply the rule condition that you both suggested to all dropdowns moving forward.

 

 


Reply