Condition Builder in UI page

surya123
Mega Guru

Hi All

I am trying to add a condition type field in ui page.

I used the page https://community.servicenow.com/community?id=community_question&sys_id=d52d43a9db9cdbc01dcaf3231f96... for my set up.

 

I see the alert on client side to get the condition field value and it works.

But how do I fetch it in the processing script?

 

Please help

Thanks

Surya

8 REPLIES 8

Satyanarayana C
ServiceNow Employee
ServiceNow Employee

Hi,

Please try the below given method and see if it works for you.

1. Use <g:ui_form> in the html

2. On submit of the page, pass the value to a hidden input field.

3. Use that value in the processing script.

find_real_file.png

Thanks

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Surya,

Can you share your code here?

I think you are referring that you are able to get the condition field value in client script and want it in processing script?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

This is the script

HTML

<g:ui_form>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<table width="100%" cellpadding="0" cellspacing="0">

<g:ui_element table="sys_script" field="collection" id="6d5f3906db011010140a7b60399619fc"></g:ui_element>
<g:ui_element table="sys_script" field="filter_condition" name ="filter_condition" id="8c9e7dc2db011010140a7b60399619f9"></g:ui_element>
</table>

<table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="left" nowrap="true"><br /><g:dialog_buttons_ok_cancel ok="return validateForm();" cancel="return onCancel();"/></td></tr>
</table>
</g:ui_form>


<script>


addLoadEvent( function() {
document.getElementById("sys_script.collection").value = "sys_user";
document.getElementById("select2-chosen-1").innerHTML = "sys_user [sys_user]";
//document.getElementById("s2id_sys_script.collection").hide();
loadFilterColumns('sys_script.filter_condition', 'collection');
});

 

Client script

addLoadEvent( function() {

document.getElementById("sys_script.collection").value = "sys_user";
document.getElementById("select2-chosen-1").innerHTML = "sys_user [sys_user]";
//document.getElementById("s2id_sys_script.collection").hide();
loadFilterColumns('sys_script.filter_condition', 'collection');
});


function validateForm() {
var m= alert(getFilter('sys_script.filter_condition'));}

Through this last line I get the condition builder entered. What i want is to redirect to all records with same condition builder so I wanted the processing script. Or if there is anyother way i can redirect to a list of records with the entered condition will also work.

 

Thanks

Surya

Hi Surya,

Can you share the HTML section and client script separately?

the addLoadEvent is present in html or client script

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader