List choice UI ACtion

Shariar
Tera Contributor

Hello everyone,

I have a Ui action, which I use on listview.

find_real_file.png

here is the code u in action,

///////////////////////////

var className = 'u_cmdb_ci_client_software';

current.sys_class_name = className;

// Mapping

var gr = new GlideRecord(className);

gr.initialize();

gr.u_escalation_route = current.u_escalation;

gr.u_legacy_document_link_1 = current.u_link_1;

gr.u_legacy_document_link_2 = current.u_link_2;

gr.u_vendor_support_details = current.u_vendor_support_details;

gr.u_sla_category = current.u_category;

gr.u_info_classification = current.u_information_classification;

gr.owned_by = current.u_owner;

gr.u_superusers = removeDuplicates([current.u_super_user_1, current.u_super_user_2]).join();

gr.u_technicians = removeDuplicates([current.u_tech_res_1, current.u_tech_res_2]).join();

gr.u_customer_technicians = removeDuplicates([current.u_tech_res_cust_1, current.u_tech_res_cust_2]).join();

gr.u_legacy_fp_change = current.u_cms_legacy_fp_change;

gr.u_admin_account = current.u_admin_account;

gr.u_security_group = current.u_security_group;

gr.u_ad_group = current.u_ad_group;

current.update();

current.u_escalation_route = gr.u_escalation_route;

current.u_legacy_document_link_1 = gr.u_legacy_document_link_1;

current.u_legacy_document_link_2 = gr.u_legacy_document_link_2;

current.u_vendor_support_details = gr.u_vendor_support_details;

current.u_sla_category = gr.u_sla_category;

current.u_info_classification = gr.u_info_classification;

current.owned_by = gr.owned_by;

current.u_superusers = gr.u_superusers;

current.u_technicians = gr.u_technicians;

current.u_customer_technicians = gr.u_customer_technicians;

current.u_legacy_fp_change = gr.u_legacy_fp_change;

current.u_admin_account = gr.u_admin_account;

current.u_security_group = gr.u_security_group;

current.u_ad_group = gr.u_ad_group;

current.update();

function removeDuplicates(a) {

    var r = new Array();

    o:for(var i = 0, n = a.length; i < n; i++){

          for(var x = 0, y = r.length; x < y; x++){

                if(r[x]==a[i]){

                      continue o;

                }

          }

          r[r.length] = a[i];

    }

    return r;

}

//////////////////////////

ui action should take the they chose ci's, and convert from a ci classe to another ci classe.

find_real_file.png

What I need is, a confirm button that pops up before the code runs.

so i can confirm that i want to convert the ci i select from the list.

confirm (some text '); does not work, since the user in client side scripting.

can anyone help me here?

Thanks.

1 ACCEPTED SOLUTION
12 REPLIES 12

Hello again



i try to make a onSubmit Client Script, but i can get it to run.


where should I create the client script on current table or, the convert class table : u_cmdb_ci_client_software ?


When i chooes my ci's and click the button, i just redirect to welcom.do page.


The ci's are convert but i did not get any confirming first.



Do you have any idea why ?



onSubmit code:



function onSubmit() {


  //Type appropriate comment here, and begin script below


  if(g_form.getActionName() == 'client_sw_to_bs'){


  var result = confirm("Do you want to CONTINO ");


  if(!result){


  return false ;


  }


  }


}




Ui Action code:



Action name: client_sw_to_bs


Show insert : true


Show update: true


List choice: true



script code:



var className = 'u_cmdb_ci_client_software';


current.sys_class_name = className;


// Mapping


var gr = new GlideRecord(className);


gr.initialize();



gr.u_escalation_route = current.u_escalation;


gr.u_legacy_document_link_1 = current.u_link_1;


gr.u_legacy_document_link_2 = current.u_link_2;


gr.u_vendor_support_details = current.u_vendor_support_details;


gr.u_sla_category = current.u_category;


gr.u_info_classification = current.u_information_classification;



gr.owned_by = current.u_owner;


gr.u_superusers = removeDuplicates([current.u_super_user_1, current.u_super_user_2]).join();


gr.u_technicians = removeDuplicates([current.u_tech_res_1, current.u_tech_res_2]).join();


gr.u_customer_technicians = removeDuplicates([current.u_tech_res_cust_1, current.u_tech_res_cust_2]).join();



gr.u_legacy_fp_change = current.u_cms_legacy_fp_change;


gr.u_admin_account = current.u_admin_account;


gr.u_security_group = current.u_security_group;


gr.u_ad_group = current.u_ad_group;



current.update();



current.u_escalation_route = gr.u_escalation_route;


current.u_legacy_document_link_1 = gr.u_legacy_document_link_1;


current.u_legacy_document_link_2 = gr.u_legacy_document_link_2;


current.u_vendor_support_details = gr.u_vendor_support_details;


current.u_sla_category = gr.u_sla_category;


current.u_info_classification = gr.u_info_classification;



current.owned_by = gr.owned_by;


current.u_superusers = gr.u_superusers;


current.u_technicians = gr.u_technicians;


current.u_customer_technicians = gr.u_customer_technicians;



current.u_legacy_fp_change = gr.u_legacy_fp_change;


current.u_admin_account = gr.u_admin_account;


current.u_security_group = gr.u_security_group;


current.u_ad_group = gr.u_ad_group;



current.update();



function removeDuplicates(a) {


    var r = new Array();


    o:for(var i = 0, n = a.length; i < n; i++){


          for(var x = 0, y = r.length; x < y; x++){


                if(r[x]==a[i]){


                      continue o;


                }


          }


          r[r.length] = a[i];


    }


    return r;


}


Gurpreet07
Mega Sage

Hi Shariar,



The client script should be on your current table and the code seems to be correct to me. but here's a catch, Client scripts work on for but not on lists. I was wrong about the implementation.


Shariar
Tera Contributor

thanks everyone for your help,


Solved the problem with   sending sys_id with g_list.getChecked ().


I took a database lookup on sys_id that was sent over to the server side, and changed sys_class_name.