开发者

KRL: Pragmatically access current ruleset id

开发者 https://www.devze.com 2023-03-30 05:25 出处:网络
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;

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 bet开发者_JAVA百科ter to have the current ruleset in a variable and use that in my notify() action.


In the pre block of a rule you can

rid = meta:rid();

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

Example:

KRL: Pragmatically access current ruleset id

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;
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消