How do you evaluate the condition_string type field?

michaelrodway
Tera Contributor

I currently have a config type form and on this form I have created a condition string field that I wish to evaluate in a Business Rule for a different form.

The behavior would be very similar to a Business Rules condition field.

        ie. Condition = gs.hasRoles('admin')

I have tried both GlideFilter and GlideScopedEvaluator, but neither seem to be correct.

I have also tried bringing the condition string that i am trying to evaluate right into my Business Rules Condition field:

ie. Condition = current.u_config.getRefRecord().getValue('u_conditions')

Ultimately, I am trying to put the condition of the BR as a configuration

So the following condition should work:

find_real_file.png

the same as:

find_real_file.png

5 REPLIES 5

Rahul Jain11
Kilo Guru

Hi Michael,



You can use the GlideFilter to evaluate the condition builder field against a record. Condition builder field stores the condition in ecodedQuery format.



Let say recGR is the record where the condition string filed(u_condition) is placed. Then, do the following to evaluate it against your current record in BR condition:



GlideFilter.checkRecord(current, recGR.u_condition))



Hope this help !!!



Regards,


Rahul Jain


Hi Rahul,



Thanks for the response.



I did look into this, however I am trying to evaluate things like the current user, his roles or groups and potentially other conditions against the current record.



Regards,


Mike


I need to have a condition that will check to see what view the form is opened in

as opposed to checking for a value in a field on the form or in the db.

Is there a way to do this?

I need this because I want to open a form with a different process flow formatter depending upon what view the form is opened in.

scottl
Kilo Sage

Just pass the condition string field through an anonymous function.

if (!new Function('return '+ condition)()) {
     // failed condition
}


If your condition string needs to evaluate 'current', just declare 'current' within the scope of the script, if it hasn't already.

var current = gr;

if (!new Function('return '+ condition)()) {
     // failed condition
}

Note: This will not work for the field type "conditions".