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

This should give the sys id's of the record that have been selected



g_list.getChecked().toString()


Thank you Kalai,


I've rewritten the UI Action and I'm able to pass across the list to the script include using 'g_list.getChecked().toString()', where I can then do anything I need to server side.


Jamie.


rafael_merces2
Tera Guru

I agree with Kalaiarasan.



I copied your button code and simulated it on my personal instance. Although the confim message appears, the g_form does not seems to work on list/



This is the error message:



Uncaught ReferenceError: g_form is not defined



Anything that you are trying the achieve that has to be done specifically from the list and that needs the g_form function?