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

nayanawadhiya1
Kilo Sage

Hello,



You can combine client and server side code in UI Action. Please refer below for your reference:


UI Action:


Action Name : ui_action_test


Client : true


Onclick : combTest()


Script:


function combTest(){


//write client side code for example,


  var answer = confirm("Do you want to proceed?");


      if (answer == true)


gsftSubmit(null, g_form.getFormElement(), 'ui_action_test'');


else


return false;


}



if (typeof window == 'undefined')


      callServercombTest();



function callServercombTest(){


//write server side code for example.


}


Hello



I know, but g_form.getFormElement() don't work in a list action so I can't combined server and client script...


If you try to test it you will see..


Try to create a ui action button with list choice true.


Then do one thing write all server side code in script include and call it if answer is true.


I was thinking about that, but how can I send current to server side.


How can the server side script know which CI it will update?


Do you have a example?