Search Results for

    Show / Hide Table of Contents

    Rule overview

    Casewhere is a rule-based system, meaning rules are used throughout the entire system for making business decisions such as triggering processes, workflow navigation, data validation, access control, etc. Rules in Casewhere are scripted in CSharp. On top of that, Casewhere provides a set of APIs for interacting with Casewhere objects, e.g., you can make a rule to prevent users not in a configurable whitelist from accessing a specific web page.

    Casewhere has the following types of rules:

    • Data trigger rule: Decide when to trigger a workflow based on data conditions.
    • Web trigger rule: Decide when to trigger a workflow based on input from the web request.
    • Access rule: Control user access to worker sites, pages, and widgets.
    • Data protection Rule: Securing data access, control data ownership, etc.
    • Workflow navigation rule: Control the navigation of workflow.
    • Scalar-function rule: Rule is used as a computing function.

    Rule syntax

    There are two syntaxes of scripting rules.

    Expression syntax

    This syntax is most suitable for simple rules.

    @do.Status != "ReadyForSend"
    

    Function syntax

    This syntax is suitable for more complex rules, which are better organized using multiple script lines. You have to begin with the #predicate keyword and return the value explicitly.

    #predicate
     
    // Parse the request header
    var dataApi = @apiFactory.Get<IDataApi>();
    if (!@headers.ContainsKey("Authorization"))
    {
        return false;
    }
    
    // Query Api Keys in DB
    var headerKey = @headers["Authorization"].First();
    var filter = FilterBuilder.Create().Eq("ApiKey", headerKey).Eq("Active", true).Build();
    var found = dataApi.Any("Applications", filter);
     
    return found;
    
    In This Article
    Back to top Generated by DocFX