List choice UI Action not working on client side.

Rohant Joshi2
Kilo Expert

Hello All,

 

I got a small requirement to close all the Incidents in one go, for that I create a List choice UI action. Problem I am facing is as we know for List choice the code will execute as much times as much records are selected from the list view.

 

Just to give some good user interactive view I tried giving up the pop up before user executes the code of UI Action. But in that case my code is not working.

Here I am putting snippet :

action name is : force_close

client callable : true

 

function onForceCloseClick()

{

    var conf = confirm("Are you sure you want to close all the selected incidents?");

    if(conf==false)

          return false;

         

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

 

}

 

      if(typeof window == 'undefined'){

      commitFC();

    }

 

function commitFC(){

    gs.log('Entering the commitFC');

    var sys_ids = action.get("sysparm_checked_items");

    //gs.log('Force Closure of Incident start... '+sys_ids);

    var inc = new GlideRecord('incident');

    inc.addQuery('company.name', 'ABC');

    inc.addQuery('active', true);

    inc.addQuery('caller_id.name','Proactive');

    inc.addQuery('incident_state', '!=', 7);   // closed = 7

    inc.addQuery('sys_id',current.sys_id);

    inc.orderBy('sys_created_on');

    inc.query();

      while (inc.next()) {          

      inc.incident_state = 7;      

      inc.update();

      gs.log('"UPDATE INCIDENT: updated ' + inc.number);

  }

}

 

Here, I have both client side and server side code, using above code I am able to get the pop up but it not progressing further.

And in case if I remove everything and keep just the server side code everything is working fine. I want to know is there any limitation for List Choice type of UI action where we can run both server and client side code simultaneously.

7 REPLIES 7

Kalaiarasan Pus
Giga Sage

Isn't this a mistake?



inc.addQuery('sys_id',current.sys_id);


Hi Kalai,



It worked fine for me when I remove everything except the server side code.



From everything   I mean onClick function(), gsftSubmit(), typeOfWindow......


gaia
Tera Contributor

Hi Rohant,
did you found solution for this problm ?


viktor_lukashov
Giga Contributor

Hi Rohant,



For list UI Actions g_form is not available (therefore g_form.getFormElement() is undefined). Instead of calling



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



to proceed to the server side, you need to call



g_list.action('[sys_id of the force_close UI action]', 'force_close');



Note though, that this functionality is not documented in the Wiki (or I have not been able to find it there).



Cheers,


Viktor