ATF: Custom step configuration output not accepted by Date/Time-field

Inactive_Use257
Kilo Explorer

Hello,

I'm implementing tests with the Automated Test Framework and not all out-of-the-box test steps fill my needs. Currently I am in need of a step that would return a DateTime variable that points to a custom amount of time (e.g. 24 hours and 5 minutes) from now. This value could be then used as a reference in another test step. 

My custom test step has integer inputs for amount of seconds, minutes, hours and days the datetime has to be from now and the output is a Date/Time value containing the result.

The step I want to use this as a reference to is a Record Producer with a field of type Date/Time. When using the custom steps output as a reference to the latter, the value is not filled. Instead, it fills up with stuff like '{{step['4e4772b6b974d300f64bad8213825381'].u_output_date}}'...

My step code might not be of use in this case, but I'll still paste it here. This case does not have any input values but instead just outputs the current UTC datetime:

(function executeStep(inputs, outputs, stepResult) {
 
 var UTCTime = new GlideDateTime();
 outputs.u_output_date = UTCTime;
 
 stepResult.setSuccess();
 
}(inputs, outputs, stepResult));

Anything I'm doing wrong?

3 REPLIES 3

Tim Deniston
Mega Sage
Mega Sage

Some of the Test Step Config records that come with the platform create outputs like this:

	stepResult.outputs.record_id = formSysId;
	stepResult.outputs.table = formTable;

Have you tried using that format? 

 

Have your output variables been defined in the related list at the bottom of the test step config? 

 

If all else fails, try this:

outputs.u_output_date = UTCTime.getDisplayValueInternal();

Inactive_Use257
Kilo Explorer

Thanks for the tips Tim.

 

However, I did not manage to solve the problem with them. What I did manage to do, was to realise that my problem was more fundamental than I first anticipated: I cannot produce a single output (neither with type DateTime nor with type String) that would nicely fill in a text field. Instead, I get getting those '{{step['4e4772b6b974d300f64bad8213825381'].u_output_date}}' fills.

 

I have defined the output-variables in the related list.

 

The first suggestion throws me an error:

Test failed due to JavaScript error executing step:
sys_atf_step.4e4772b6b974d300f64bad8213825381 : Line(4) column(0)
1: (function executeStep(inputs, stepResult) { 
2: 
3: var UTCTime = new GlideDateTime(); 
==> 4: stepResult.outputs.u_date_string = UTCTime; 
5: 
6: stepResult.setSuccess(); 
7: 

Full logging from step execution:
11:03:50.50: Evaluator: org.mozilla.javascript.EcmaError: Cannot set property "u_date_string" of undefined to "2018-03-20 09:03:50"
Caused by error in sys_atf_step.4e4772b6b974d300f64bad8213825381 at line 4

and the second produces the same output as initially.

 

Logging the output with Log-test step does output everything correctly, but trying to insert the output to a form field gets always messed up. 

Jochen Geist
ServiceNow Employee
ServiceNow Employee

Is this a client-side step?

If yes, try:

var UTCTime = new GlideDateTime();
 outputs.u_output_date = UTCTime.getDisplayValue();