The CreatorCon Call for Content is officially open! Get started here.

Multiple OnClicks within a UI Action is it possible?

adam0907
Kilo Explorer

I have a UI Action called "Submit for Review" on a form that I want to execute 2 events when I clcik on it.

Event 1)Move the record onto a different phase

2)Send an Email to numerous people advising of the change of phase.

I use the following OnClick event to move the record to the next phase.

OnClick = moveToReview()

function moveToReview(){
  removeMandatoryFieldsReview();
  gsftSubmit(null, g_form.getFormElement(), 'move_to_review'); //MUST call the 'Action name' set in this UI Action
}

if(typeof window == 'undefined'){
    moveToReviewServer();
}

function moveToReviewServer(){
    action.setRedirectURL(current);
    current.state = '13';
    current.u_release_phase = 'In Progress';
    current.update();

But can I add another one into this script to send out emails ie

Onclick = sendreviewemail

function sendreviewemail(){
      var release_number = g_form.getValue("number");

//Initialize and open the Dialog Window
    var dialog = new GlideDialogWindow("email_preview_rel_in_prog");
    dialog.setSize(1200,1200);
    dialog.setTitle("Release Review Request Notification Preview");
    dialog.setPreference("release_number", release_number);
     
  dialog.render();

      action.setRedirectURL(current);

Appreciate any help with this.

Cheers Adam

8 REPLIES 8

User140988
Kilo Guru

hi Adam,



I was wondering why do you need a client UI action to do this job. You can still do this with a server side UI action, to change the status of the record and also the send an email via eventQueue and configuring an event and email notification. Will this not satisfy the usecase


adam0907
Kilo Explorer

Hi Chandana



I was just using what was in place already and trying to adapt. Is it best to move both events into a single Server side UI action or keep the events seperate.



Apologies for the dumb questions Im new to this development piece so am trtying to find my feet.


Cheers Adam


HI Adam,



Server side is definitely faster and more efficient than client side. For your usecase if you dont have to show any user messages or wait for any user action, you can use server side UI action to do both the jobs.


marcguy
ServiceNow Employee
ServiceNow Employee

The popping up of the GlideDialogWindow will need to happen in the client before the server side function gets called and run, because when that runs the record is going to refresh.



As the others say though if you don't need pop ups or any client side interaction, move it to server side, client stuff should only be if you need to alert the user to fill more stuff in, or ask them more questions or pop something up etc.



cheers,


Marc