Using variable conditions builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 09:37 AM
I was wondering if there could be a way to mimic the condition builder which is on Catalog UI Policy where selecting a catalog item gives an option to select a variable from the "catalog conditions" field.
I have created a form with Catalog item and Condition field (dependent on catalog item). And the requirement is to show the variables in the filter option-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 12:58 PM
You probably don't have this requirement anymore, but I just wanted to chime in with a solution I just got working.
Setting up your field just like you did, if you just add an onLoad Client Script that calls the GlideFilter constructor like this, it will make your Catalog Conditions field work.
function onLoad() {
new GlideFilter("sn_hr_sp_dropzone_config.u_conditions", g_form.getValue("u_conditions"), null, false, false, function(filter) {
filter.tableOptions = {
onBeforeReadColumns: function(ajax) {
ajax.addParam("sysparm_condition_builder", "true");
ajax.addParam("get_catalog_variables", "true");
ajax.addParam("sysparm_sys_id", g_form.getValue("u_record_producer"));
ajax.addParam("sysparm_record_scope", "global");
ajax.addParam("sysparm_value", "catalog_ui_policy");
}
};
});
}
The first argument is <table_name>.<field_name>
The second is the query to add (will most likely just be the same field as your Catalog Conditions field)
Third, fourth and fifth I'm not entirely sure what are used for, but I just left them off.
The final argument is a callback function, and you'll need to set the filter's tableOptions property to an object with the onBeforeReadColumns function as specified.
Whenever a GlideFilter is used on a non-Catalog UI Policy table, it seems to always grab the variables that are on the actual table the Catalog Conditions variable is defined on. In my case, that would be sn_hr_sp_dropzone_config. If you instead just set sysparm_value=catalog_ui_policy, event though the table isn't Catalog UI Policy, it grabs the variables from the Record Producer specified in sysparm_sys_id.
Here's my Catalog Conditions field (Conditions) on my custom table Dropzone Config. There's a Record Producer in a reference field called u_record_producer, that it's currently pulling the variable test_string from.
Saving the record after setting some conditions will correctly save it in the database, and the onLoad Client Script will load it in the Conditions field on the form, just like in a regular Catalog Conditions field.
I hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2025 06:59 AM
I have to say that you saved my life, thank you!!!!