Blog

Model driven apps - 3 use case scenarios of how to set default record values

A routine requirement is to set default field values. We use business rules to set default values, but the specific settings that we need to apply may not be exactly clear. To provide some practical examples, this post covers 3 typical scenarios - including how to set default field values for new records, default values that depend on other fields, and default values that depend on the app.

To set default values in model driven apps, we define business rules at the table level. The specific details of how to set-up a rule may not be entirely obvious so in this post, we'll cover three typical use case scenarios.This includes how to set a default value for a new record, how to set a default value that depends on another value, and how to set default values differently depending on the app.

1 Setting default values for new records

A very frequent requirement is the ability to define a default value when a user creates a new record. The confusing thing is that each business rule must start with a condition, and it may not be obvious what that condition would be.

The trick is to build a business rule that begins with the condition "created on does not contain data". This will be true for new records, and we can use this to set default values for new records.


In the example beneath, we add a "set default value" action to the true branch to set the value of the country field to "England".


2 Setting default values, depending on other field values

A second use case scenario is to set a default value that depends on the value of another field. We can implement this rule by creating a condition that references the target field. In the example beneath, we create a condition that defaults the "tax band" field to "D" if the "aquisition price" field is less than $500,000.


By chaining the conditions, we can set default values based on bandings. The screenshot beneath shows the visual appearance of a business rule the implements the following pseudo-code.

If(AquisitionPrice < 500,000, "D",
AquisitionPrice < 750,000, "C",
AquisitionPrice < 1,500,000, "B",
"A"
)


3 Setting default values, depending on the form or app

Another typical requirement is ability to set default values that depend on the app or form that the user uses. To fulfil this type of requirement, we set the scope of the business rule.

This setting may not be obvious because it appears in the top right-hand corner of the designer. By changing the scope, we can configure a business rule to apply to apply to a specific form.


If we define a form for specific use in a single app only, applying a business rule to the form will by extension apply the rule to target app only.

Conclusion

In this post, we covered 3 examples of how to apply default values with business rules.This included how to set a default value for a new record, how to set a default value that depends on another value, and how to set default values differently depending on the app.
Related posts