- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 07:16 AM
Hello everyone,
I have a Ui action, which I use on listview.
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.
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 08:25 AM
Hi!
Check the existing Delete UI Action, I think it's exactly what you need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 09:56 AM
Like this you can pass current object into script include -
var ga = new GlideAjax('scriptinclidename');
ga.addParam('sysparm_name','outge');
ga.addParam('sysparm_sysid',g_form.getValue('fieldwithsysiduwanttopass'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var obj = JSON.parse(answer);
alert(obj.short_desc); //result
alert(obj.cmdb_ci); //result
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 10:49 AM
i can not use g_form but, maybe i can use g_list.getChecked(). then i get the sysID.
i'm gonna try and come back if it works thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 08:25 AM
Hi!
Check the existing Delete UI Action, I think it's exactly what you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 08:26 AM
Assign some action name for this UI Action and then write a onSubmit Client script.
if(g_form.getActionName()=='ui_action_name'){
var result = confirm("Type Message Here");
if(!result){
return false ;
}
}
Its just an observation that .. you are having multiple of current.update() statements. You could keep last on and remove others. Also you have initialized gr but do not have insert() statement , seems like you are not inserting any records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 08:36 AM
I'm not inserting, just moving a CI from one class to another.
I'm gonna test your method and come back to you
Thanks for the help guys☺�