Skip to content

Rule with dynamic parameter #48

@roneetshaw

Description

@roneetshaw

This is my rule

{
    "location": "here",
    "rule": {
        "action": {
            "code": "var msg ='Name :' + who + ' age : '+x; console.log(msg); msg;"
        },
        "condition": {
            "and": [
                {
                    "pattern": {
                        "age": "?x",
                        "name": "?who"
                    }
                },
                {
                    "code": "x >6"
                }
            ]
        },
        "when": {
            "pattern": {
                "age": "?x",
                "name": "?who"
            }
        }
    }
}

In the above JSON, I am checking with constant 6 where age> 6 in my condition, but is there a way where I can pass a variable instead of fix values from the uri: /api/loc/events/ingest
For example
uri: /api/loc/events/ingest
request

{
    "location": "here",
    "event": {
        "age": "8",
        "name": "sonu"
    }
}

The age passed here i.e. 8 should be used in the rule condition and the result should be according to that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions