Search Results for

    Show / Hide Table of Contents

    Attribute default value

    Object creation is often complex. Repeating object creation logic across different workflow definitions is not a good practice because updates may be missed. Casewhere allows you to configure default values for data attributes using rules.

    Configuration

    Casewhere uses scalar-function rules to calculate default values. In the data class editor, select the data attribute you want to configure a default value for, then select a rule or write a new one. The rule must use the Attribute Default Value rule scope; its expression can access the object being created via @do, the current user via @user, and Casewhere APIs via @apiFactory. The default is applied only when a new object is created without an explicit value for the attribute.

    image-20220629221748554

    Please note that if you specify a value for the attribute when creating a new object, Casewhere will persist this value and ignore the rule. In the below example, the created message will have status Sent instead of the default value Draft.

    var dataApi = ctx.Use<IDataApi>(); 
    dataApi.Add("CwUatTx2Message", new 
    { 
        Status = "Sent", 
        Content = $"Application {ctx.Input.Name} is {ctx.Input.Status}" 
    });
    
    In This Article
    Back to top Generated by DocFX