Simple Data Rule is not working when the field does not allow nulls

Origam version: HTML, 2021.2.0.2398

I was trying to …

  1. I have a simple data rule to fill the value of another field when the field is empty:
    obrazek
  2. The rule works fine when the field Firma is not mandatory.
    obrazek

I was expecting …

  1. When I change the field to be mandatory, I would expect that the rule will be still working.

Instead I’ve got …

  1. The rule is not working now.

obrazek

This is not bug. This is a feature.

Yes, exactly! The reason is that rules that require another field, e.g. those that subsequently look up something based on a mandatory value, would typically fail when executed. So we wait until those are filled and only then evaluate the rules that depend on them.

It would be interesting to hear your use case. Why does it bother you?

Hi Tomáš,

thank you for additional information. What I want to achieve:

  1. I have a field Customer which is mandatory field.
  2. I have a field called Company - the company where the goods are suppossed to be delivered. This field I wanted to have also mandatory but prefilled by the value which user input into field Customer.
  3. The user can select the address which belong to the Company.

Company is mandatory because it is what is actually printed on the Delivery Note. They can deliver the goods into different Company instead of the customer.

So the rule ensures that the field Company is prefilled when the user selects Customer. But the user can change the value of the field Company. The user can also delete the value and in this case the mandatory condition is not applied (because I had to set up the field as not mandatory to make that rule work).

So at the moment I have a setup:

  1. Field Customer is mandatory (entity does not allow null)
  2. Field Company is optional (entity does allow nulls) but the database column is set to not accept NULL values.

What was espeacially confusing for me was that I modeled it first with non-null field. So the rule worked well. And then I revise my data model and wanted to enforce the data integrity and made that field mandatory. And the rule stopped working. So I tracked back what have changed and found this (for me) strange behaviour.

Is the only reason that you need to reset the Company when the user changes a customer in order to pre-fill another “default” company for that customer? Because the only time the rule for the Company field won’t run would be when you delete the Customer field. Then I think it makes no sense to have anything written in the Company field so I guess you want to empty it?

For that we would have the tool Dependency (under an entity field – you can relate one field to another). Exactly this part of the model defines which fields are dependent on what other fields. Because we cannot model this behaviour in the rules. Whenever a field changes, all the dependent fields get reset prior to evaluating rules on them (if any). This way you can e.g. always “re-evaluate” the Company field when the parent Customer field changes value.