Need to trigger an event from a Wizard onSubmit Client Script

User382122
Tera Contributor

Hi, 

 

I need to trigger an event from a wizard onsubmit client script. 

 

And I could use your help? 

 

THANKS 

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@User382122 You need to call a Script Include via GlideAjax in the onSubmit script and trigger the event from the script include as follows.

 

function onSubmit() {
   var ga = new GlideAjax('TriggerEventSI'); // GetUserInfo is the script include name 
   ga.addParam('sysparm_name','triggerEvent'); // triggerEvent is the function in the script include that we're calling 
   ga.addParam('sysparm_event_name','some.event'); // name of the event

   ga.getXMLAnswer(eventParse);  		
}

// callback function for returning the result from the script include
function eventParse(response) {  
   alert(response);
}

 

Here is the script include.

 

// TriggerEventSI script include 

var TriggerEventSI = Class.create();
TriggerEventSI.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    TriggerEvent: function() {
        var eventName = this.getParameter("sysparm_event_name");
        gs.eventQueue(eventName,current,'param1','param2');//replace param1 AND param 2
    },
    type: 'TriggerEventSI'
});

 

Hope this helps.

 

@Sandeep Rajput Thanks for your fast response: 

 

On quick question: my event name is gui.cr.update. Would I write this where ist says 

 

ga.addParm('sysparm_event_name', 'gui.cr.update'); 

var eventName = this.getParameter('gui.cr.update'); 

 

Lastly, Is there anything else that I need to update from this script.

 

 

thanks 

@User382122 Yes, your assumption is correct.

 

Following code would be added to the client script.

ga.addParm('sysparm_event_name', 'gui.cr.update'); 

 

In the script include following line should be written

var eventName = this.getParameter('gui.cr.update'); 

 

Make sure your Script include is client callable.