Evaluating a GlideRecord based on a Condition field?

andersba
Giga Contributor

I am attempting to do an achievements/gamification application that will allow an administrator-type to specify different Achievement records with a "Condition" field type.   This way they can use drop downs similar to how they build list filters to say how achievements should be awarded, instead of having to write some Javascript for everything (since they will be managers, not necessarily coders).

So in my master business rule that runs the evaluation, I want to be able to say something like:

var ach - new GlideRecord('u_achievements');

//query all achievements here

while (ach.next()) {

        if (current.matchCondition(ach.u_condition))

                  //do stuff

}

I know ach.u_condition will return an encoded query string, which I could use to query a list or something, but that doesn't really let me do this.

I could parse the query string myself and convert it into evaluatable lines of code, but obviously I don't want to reinvent the wheel if I don't have to.   Has anyone managed to accomplish this?

1 ACCEPTED SOLUTION

German Alvarez2
Tera Expert

GlideFilter class will be the key!



value = GlideFilter.checkRecord( current , ach.u_codition);


View solution in original post

3 REPLIES 3

German Alvarez2
Tera Expert

GlideFilter class will be the key!



value = GlideFilter.checkRecord( current , ach.u_codition);


That's exactly what I needed - must just not have used the right terms when I was searching. Thanks!


Believe me, it's really hidden, I found it one day dealing with SLA Condition Base ... I came there to rescue this snippet for you.