Urgent assistance with Execution of UI action from Schedule Job

sunny27
Tera Contributor

Hi All, 

I have requirement where I need to create a schedule Job which runs every 30mins and it should execute a "Test connection" UI action in it.  As per the UI action's result a notification should send to certain group.

UI Action: (Onclick : testAccountConnection(); )

var title = getMessage('Connection Test');

function testAccountConnection() {

var gm = new GlideModal('email_connection_test', false /*read-only*/ );
gm.setTitle(title);
gm.setWidth(500);
gm.render();

}

 

I have tried to copy paste the UI action's script in Script Include. And updated schedule job with "new emailAccountTestConnection().emailTestConnection();"

In Script Include : 

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

emailTestConnection: function() {

var title = getMessage('Connection Test');
var gm = new GlideModal('email_connection_test', false /*read-only*/ );
gm.setTitle(title);
gm.setWidth(500);
gm.render();
return gm;
},

type: 'emailAccountTestConnection'
});



But I'm facing com.glide.script.RhinoEcmaError: "getMessage" is not defined or com.glide.script.RhinoEcmaError: "GlideModal" is not defined.

 

Could you please advice any preferable steps to complete this task ? Its quite urgent now. 

 

 

Thank you

 

1 ACCEPTED SOLUTION

DrewW
Mega Sage
Mega Sage

You are not going to be able to run a client side UI action via a scheduled job.  Especially one that opens a dialog.  You are going to have to understand how the UI Page/UI Macro "email_connection_test" works and do the same thing that does in your scheduled job.

View solution in original post

6 REPLIES 6

sunny27
Tera Contributor

Hi @Ratnakar7 , Thank you !! I will definitely try this steps once I found the UI page ( "email_connection_test" ) and the table details its using.

Several other ways you can search for this.

1 - Install the SN Utils plugin in Chrome and use its code search option.

2 - Turn on text indexing for the sys_metadata table and then do a search for email_connection_test.

 

I did the second one and the UI page/Macro does not exist in a way that will allow you to see the code.  You are going to have to log a support case to see if ServiceNow will help you with understanding how to do what you need to do.