UI Action - List Button

Jamsta1912
Tera Guru

Hello,

I'm trying to write a UI Action to perform some operations on multiple records selected in a list. I've created the UI Action and selected 'List Button'.

I'm using this well tried and tested method from SNC Guru, to run a client side script before the server side script, to give the user a confirmation alert message:

//Client-side 'onclick' function

function runClientSide(){

    if(confirm('Do you want to continue?') == false){

          return false;   //Abort submission

    }

    //Call the UI Action and skip the 'onclick' function

    gsftSubmit(null, g_form.getFormElement(), 'myAction'); //MUST call the 'Action name' set in this UI Action

}

//Code that runs without 'onclick'

//Ensure call to server-side function with no browser errors

if(typeof window == 'undefined')

    runBusRuleCode();

//Server-side function

function runBusRuleCode(){

  gs.log('The BusRuleCode ran OK.');

}

I am able to get the client side script to run, but can only get the server side script to run if I uncheck the 'Client' box (in which case I lose the alert message).

Presumably the issue is with the getFormElement row (as the form isn't visible in list view).

Can anyone advise how I would modify this code to make it suitable for a List Button UI Action?

Thanks

Jamie.

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

Would it be a issue to convert all the server side code to a script include function ? I don't think g_form.getFormElement() function will work on list layout.


View solution in original post

7 REPLIES 7

rafael_merces2
Tera Guru

Your UI Action must have an action name. There, in myAction goes this action name. Change this and check if it works.


Hi Rafael,



Thanks for the reply.


My UI Action has the action name 'myAction'. Here's a screenshot of the UI Action form in case there's something obviously wrong that a second pair of eyes would quickly see:



find_real_file.png


Kalaiarasan Pus
Giga Sage

Would it be a issue to convert all the server side code to a script include function ? I don't think g_form.getFormElement() function will work on list layout.


Hi Kalai,



Thank you for this.


I can see that a script include function could be the way forward. How would I reference or pass in the records selected in the list (that I want to perform the UI Action on)?



Jamie.