ERROR Test failed: Can't find method com.snc.automation.TriggerSynchronizer.executeNow(string).

Ron28
Mega Sage

I just ran into this error while creating an ATF test to start a Discovery schedule.

When putting the following code in a background script, this works fine:

var schedule = 'fcc83251db4829185c863ec3f39619b6';

var grSched = new GlideRecord('discovery_schedule');		// Need to pass reference to Discovery script include
grSched.get(schedule);								        // Get Schedule record

var d = new Discovery();
var sta = d.discoverNow(grSched);

var grStatus = new GlideRecord('discovery_status');
grStatus.get(sta);

gs.print('Discovery Status Record number: ' + grStatus.getValue('number'));

// Output:
//*** Script: Discovery Status Record number: DIS4073844

 

But when running this near enough identical code via an ATF test in a scripted step I get the above error on the call to the Discovery script include, discoverNow() method:

(function executeStep(inputs, outputs, stepResult, timeout) {
	var schedule = 'fcc83251db4829185c863ec3f39619b6';
	var grSched = new GlideRecord('discovery_schedule');

	var d = new Discovery();
	var status = d.discoverNow(schedule); 				// Returns sys_id of Discovery Status record


I've hardcoded the sys_id of the schedule here only to have an identical call to the Discovery script include. 
The error:

ERROR Test failed: Can't find method com.snc.automation.TriggerSynchronizer.executeNow(string). (sys_script_include.a6cdaf5bc0a802550004f460b6c04967.script; line 46)
	org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:58)
	org.mozilla.javascript.Context.reportRuntimeError(Context.java:1570)


Thinking this was a scope issue I checked all components:

test 
re-usable test
scripted step
script include

are all in the Global app scope. The script include is unmodified, OOB. 

Any ideas what is going wrong?

 

Thanks
Ron

 

 

1 ACCEPTED SOLUTION

bonjarney
Mega Contributor

The error message is telling you the answer — it's likely a parameter type problem, not a sandbox problem.

Read the error carefully: Can't find method executeNow(string). It's not saying "access denied" or "class not found." It's saying it can't find an executeNow method that accepts a string parameter.

Your working background script passes a GlideRecord to discoverNow(). Most ATF attempts pass a string sys_id. The underlying Java class (SncTriggerSynchronizer.executeNow()) may simply not have a string overload.

2-minute test to confirm — run this in Background Scripts:

(function() {
    var grSched = new GlideRecord('discovery_schedule');
    grSched.setLimit(1);
    grSched.query();
    if (!grSched.next()) {
        gs.info('No discovery_schedule records found.');
        return;
    }
    var schedSysId = grSched.getUniqueValue();
    gs.info('Testing with STRING parameter...');
    try {
        new Discovery().discoverNow(schedSysId); // STRING
        gs.info('String worked — sandbox is the real issue.');
    } catch (e) {
        gs.info('String FAILED: ' + e.message);
        gs.info('Now test with GlideRecord in your ATF step.');
    }
})();
 

If the string fails here too â€” the root cause is parameter type, not sandbox. Fix your ATF step to query the schedule as a GlideRecord first, then pass it:

// ATF "Run Server Side Script" step — fixed
(function(outputs, steps, params, stepResult) {
    var grSched = new GlideRecord('discovery_schedule');
    grSched.get('YOUR_SCHEDULE_SYS_ID');
    var d = new Discovery();
    d.discoverNow(grSched); // GlideRecord, NOT string
    stepResult.setOutputMessage('Discovery triggered.');
    stepResult.setSuccess();
})(outputs, steps, params, stepResult);
 

If the string works in background scripts â€” then the sandbox restriction is real and the parameter type isn't the issue. In that case, ATF is the wrong tool for triggering Discovery on a schedule. Use a Scheduled Script Execution (sysauto_script) to run Discovery daily in unrestricted server context, and use ATF only to validate that Discovery ran (query discovery_status for today's record). Separate execution from validation — ATF is a test framework, not a scheduler.

View solution in original post

8 REPLIES 8

I mean what is the actual test covering as in what do you gather from a successful result from this particular test? Are you testing that the discovery schedule functionality works?

Yes that is the requirement, just for one Cloud Discovery. Additional requirements relate to checking the credentials are ok and test results are kept. On this test system Discovery generally doesn't get run so an ad-hoc run via ATF would be good.

I'll check if a particular schedule runs daily already, if that is the case I could skip starting a new discovery with the subsequent wait for result and just compare the output from the last and previous run(s). Avoiding the above issue altogether.

bonjarney
Mega Contributor

The error message is telling you the answer — it's likely a parameter type problem, not a sandbox problem.

Read the error carefully: Can't find method executeNow(string). It's not saying "access denied" or "class not found." It's saying it can't find an executeNow method that accepts a string parameter.

Your working background script passes a GlideRecord to discoverNow(). Most ATF attempts pass a string sys_id. The underlying Java class (SncTriggerSynchronizer.executeNow()) may simply not have a string overload.

2-minute test to confirm — run this in Background Scripts:

(function() {
    var grSched = new GlideRecord('discovery_schedule');
    grSched.setLimit(1);
    grSched.query();
    if (!grSched.next()) {
        gs.info('No discovery_schedule records found.');
        return;
    }
    var schedSysId = grSched.getUniqueValue();
    gs.info('Testing with STRING parameter...');
    try {
        new Discovery().discoverNow(schedSysId); // STRING
        gs.info('String worked — sandbox is the real issue.');
    } catch (e) {
        gs.info('String FAILED: ' + e.message);
        gs.info('Now test with GlideRecord in your ATF step.');
    }
})();
 

If the string fails here too â€” the root cause is parameter type, not sandbox. Fix your ATF step to query the schedule as a GlideRecord first, then pass it:

// ATF "Run Server Side Script" step — fixed
(function(outputs, steps, params, stepResult) {
    var grSched = new GlideRecord('discovery_schedule');
    grSched.get('YOUR_SCHEDULE_SYS_ID');
    var d = new Discovery();
    d.discoverNow(grSched); // GlideRecord, NOT string
    stepResult.setOutputMessage('Discovery triggered.');
    stepResult.setSuccess();
})(outputs, steps, params, stepResult);
 

If the string works in background scripts â€” then the sandbox restriction is real and the parameter type isn't the issue. In that case, ATF is the wrong tool for triggering Discovery on a schedule. Use a Scheduled Script Execution (sysauto_script) to run Discovery daily in unrestricted server context, and use ATF only to validate that Discovery ran (query discovery_status for today's record). Separate execution from validation — ATF is a test framework, not a scheduler.

You are correct, that the executeNow() method requires a gliderecord.

I think the issue is that in the test I select a schedule record and pass this as reference to a re-usable test, then this is passed as a reference to the scripted step but somewhere along the lines this reference isn't really a reference that executeNow() can use. This worked fine in the test:

    var grSched = new GlideRecord('discovery_schedule');
    grSched.get('YOUR_SCHEDULE_SYS_ID');
    var d = new Discovery();
    d.discoverNow(grSched); // GlideRecord, NOT string


I'll change the way I pass the schedule, maybe by name to make a schedule specifically for this test then retrieve this in the scripted step before running the schedule.

Thanks very much.