How to add condition builder on UI Page?

gratziela
Tera Contributor

Hi,

I created an UI page and I wanted to add the condition builder on it.

I read this article Condition Builder   and added these lines of code to my UI page:

Test 1:

<g:ui_element table="sys_script" field="collection" id="0e66a301dd2003003399d83d70be0205"></g:ui_element>  

<g:ui_element table="sys_script" field="filter_condition" id="8a66a301dd2003003399d83d70be0211"></g:ui_element>

Test 2:

<g:ui_element table="x_doitw_msteams_ih_condition_builder" field="collection" id="c3a5264e4f13030009fdb5e18110c795"></g:ui_element>  

<g:ui_element table="x_doitw_msteams_ih_condition_builder" field="condition" id="6b65a24e4f13030009fdb5e18110c717"></g:ui_element>

As you see, I tested it both with sys_script table and my custom scoped table (called x_doitw_msteams_ih_condition_builder) and in the first case it works, but in the second one - it doesn't.

My custom table is in a scoped application. It has a field of type "conditions" called "condition" and a field of type "table name" called "parent_table".

The condition field uses as a dependent field "parent_table" field.

I also want to make the table static. I don't want the user to be able to change different table. I just want he/she to be able to create a filter for my specific table.

That is why I added as a default value of "parent_table" field the name of my table.

I don't know is there a way not to use the first (table selection) input from the condition builder. For example, to autopopulate it and hide it or just to remove it (see on the picture).

Thanks in advance. If somebody has an advice, I will be glad to try it.

13 REPLIES 13

Deepak Ingale1
Mega Sage

Hi Gratsiela,



You are very fortunate that you asked this question. I was struggling to set the table as static value as well in last couple of weeks and just found a solution in a last week.



Let me find and share that with you shortly.



About scope app table, i thing if OOB sys_script table condition and filter is working for you, why not to stick to it?


document.getElementById("u_reminder_master.u_table").value = "incident";


document.getElementById("select2-chosen-1").innerHTML = "incident [incident]";


document.getElementById("s2id_u_reminder_master.u_table").hide();


loadFilterColumns('u_reminder_master.u_condition', 'u_table');



These are magic 4 lines which took me couple of weeks to figure out ( on and off kind of )



Remember, I was using u_reminder_master table where u_table is TABLE type field


You will require to replace it with appropriate table ( in your case it is sys_script and dictionary label of the condition field on sys_script ). I have highlighted the part what you will require to replace with the table what you are using for setting up the filter and condtions .



Line number 3 you can comments out, to check if table is getting set properly or not. Line number 4 is responsible for loading columns for filter based on table selected.


Note : you will require to fire this code when page loads


addLoadEvent(function() {


document.getElementById("u_reminder_master.u_table").value = "incident";


document.getElementById("select2-chosen-1").innerHTML = "incident [incident]";


document.getElementById("s2id_u_reminder_master.u_table").hide();


loadFilterColumns('u_reminder_master.u_condition', 'u_table');


});