. Create two buttons on this UI Page i. Search Incident ii. Search Problem . Depending on the click all i

snehalkhare
Kilo Guru

Please help to do this activity.

.           Create two buttons on this UI Page

                                                                                                                            i.           Search Incident

                                                                                                                        ii.           Search Problem

                                                                      Depending on the click all incident/problem should be listed in the UI Page

Pr

2 REPLIES 2

ramireddy
Mega Guru

Hi Snehal,



There will be many ways to do this. One easier way is, For the 2 buttons, implement onClick events. In those "OnClick" events, redirect to the same page with different query strings.



In the Design section of UI page, In "script" tags, you can read the query string and based on that, using GlideRecord, you can query incident/problem tables and display corresponding records.




Another approach is: In "onclick" event, use Glide Ajax to query these tables and display. This is a more javascript tedious work.


Sandeep Kumar6
Giga Guru

HI Snehal,


Please create UI page ,Script include as below you will get your answer.



UI Page:


HTML:



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


    <TABLE BORDER="0" width="600">


          <TR>


                <TD>


                      Please select the Store you wish to add.


                </TD>


          </TR>


      <TR>


                <TD align="right">


                        <button type="button" onclick="SearchIncident()">Search Incident</button>


                </TD>


          </TR>


          <TR>


                <TD>


                      <!-- Include the 'ui_slushbucket' UI macro -->


                      <g:ui_slushbucket/>


                </TD>


          </TR>


          <TR>


                <TD align="right">


                      <!-- Include the 'dialog_buttons_ok_cancel' UI macro -->


                      <g:dialog_buttons_ok_cancel ok="return continueOK()" cancel="return continueCancel()" ok_type="button" cancel_type="button"/>



                </TD>


          </TR>


    </TABLE>


</j:jelly>



Client Script:



//Called when the 'OK' button gets clicked


function continueOK(){


  //Get the selected values from the right slushbucket


  var values = slush.getValues(slush.getRightSelect());


  if(values == ''){


  alert("At least one Store must be selected");


  return;


  }


  else


  {


  g_form.setValue('u_selected_groups',values);


  }


  GlideDialogWindow.get().destroy();


  return false;


}


//Called when the 'Cancel' button gets clicked


function continueCancel(){


  //Close the dialog window


  GlideDialogWindow.get().destroy();


  return false;


}




//Called when the form loads


addLoadEvent(function(){


  //Load the groups when the form loads


  slush.clear();


  var ajax = new GlideAjax('PromotionCreationinRaymark');


  ajax.addParam('sysparm_name', 'getGroups');


  ajax.getXML(loadResponse);


  return false;


});




//Called when we get a response from the 'addLoadEvent' function


function loadResponse(response){


  //Process the return XML document and add groups to the left select


  var xml = response.responseXML;


  var e = xml.documentElement;



  var items = xml.getElementsByTagName("item");


  if(items.length == 0)


  return;



  //Loop through item elements and add each item to left slushbucket


  for (var i = 0; i < items.length; i++) {


  var item = items[i];


  slush.addLeftChoice(item.getAttribute('value'), item.getAttribute('text'));


  }


}


//Called when the form loads


function SearchIncident(){


  //Load the groups when the form loads


  slush.clear();


  var ajax = new GlideAjax('PromotionCreationinRaymark');


  ajax.addParam('sysparm_name', 'searchIncident');


  ajax.getXML(SearchIncident1);


  return false;


}




//Called when we get a response from the 'addLoadEvent' function


function SearchIncident1(response){


  //Process the return XML document and add groups to the left select


  var xml = response.responseXML;


  var e = xml.documentElement;



  var items = xml.getElementsByTagName("item");


  if(items.length == 0)


  return;



  //Loop through item elements and add each item to left slushbucket


  for (var i = 0; i < items.length; i++) {


  var item = items[i];


  slush.addLeftChoice(item.getAttribute('value'), item.getAttribute('text'));


  }


}




Script Include :



var PromotionCreationinRaymark = Class.create();




PromotionCreationinRaymark.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  //Get and return a list of groups (name and sys_id)


  getGroups: function() {


  var gr = new GlideRecord("sys_user_group");


  gr.orderBy('name');


  gr.addQuery('active', true);


  gr.query();



  //Add the available groups to select from


  while (gr.next()) {


  var item = this.newItem();


  item.setAttribute('value', gr.getValue('name'));


  item.setAttribute('text', gr.getValue('name'));


  }


  },


  getUsers: function() {


  var gr = new GlideRecord("sys_user");


  gr.orderBy('name');


  var query ="active!=false^name!=NULL^calendar_integration!=0^city!=NULL";


  gr.addEncodedQuery(query);


  //gr.addQuery('active', true);


  gr.query();



  //Add the available groups to select from


  while (gr.next()) {


  var item = this.newItem();


  item.setAttribute('value', gr.getValue('name'));


  item.setAttribute('text', gr.getValue('name'));


  }


  },


  searchIncident: function() {


  var gr = new GlideRecord("incident");


  var query ="active=true^business_duration!=NULL^location.name!=NULL";


  gr.addEncodedQuery(query);


  //gr.addQuery('active', true);


  gr.query();



  //Add the available groups to select from


  while (gr.next()) {


  var item = this.newItem();


  item.setAttribute('value', gr.getValue('number'));


  item.setAttribute('text', gr.getValue('number'));


  }


  },


});