Randall Bohn
Randall Bohn

Reputation: 2657

KRL: Pragmatically access current ruleset id

How do I get the name of the current ruleset in a KRL rule? I find that I often write

notify("a421x70","Your Message Here") with sticky = true;

but when I copy the ruleset I have to go through and change the "a421x70" part. It would be so much better to have the current ruleset in a variable and use that in my notify() action.

Upvotes: 2

Views: 33

Answers (1)

Mike Grace
Mike Grace

Reputation: 16934

In the pre block of a rule you can

rid = meta:rid();

http://docs.kynetx.com/docs/Meta_Info

Example:

enter image description here

ruleset a60x598 {
    meta {
        name "appid tester"
        description <<
            getting app rid pragmatically 
        >>
        author "Michael Grace"
        logging off
    }

    rule get_rid_rule {
        select when web pageview ".*"
        pre {
            rid = meta:rid();
        }
        {
            notify("Current App rid is", "#{rid}") with sticky = true;
        }
    }
}

Upvotes: 2

Related Questions