Record validation for "Conditions" field in ATF

Leonard Ambos
Mega Sage

I'm trying to compare a "Template Value" field in ATF, but I'm not sure that I'm using the right syntax. The field I want to validate is a reference from sn_hr_core_service to sn_hr_core_template.template, which is a "Template Value" field type (which extends "Conditions"). When I run the a background script to check the value, it looks like it prints the field as assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^

Input:

var gr = new GlideRecord("sn_hr_core_service");
gr.addQuery("name","Health Enrollment");
gr._query();
if(gr._next()){
  gs.print(gr.template.template);
}

Output:

*** Script: assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^

 

However, when I create a record validation test step to compare this field and enter this value, the description for the test step reads:

Validate record from table 'sn_hr_core_service' matches the following condition:
Template Template = assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^EQ
With a failure timeout of 5 Seconds

When I go back to modify the record validation test step, the value now appears as:

assignment_group=feb04bb91b60b3c02c476356bd4bcb18^^u_functional_area=Benefits^^EQ

And when I actually run the test, it fails with the following:

Record '5add02261b28b7400bdcbb7acd4bcb2c', in table 'sn_hr_core_service', did not match conditions: template.template=assignment_group=feb04bb91b60b3c02c476356bd4bcb18^^u_functional_area=Benefits^^EQ

 

Am I misunderstanding what the actual value is for the field? Is SNOW modifying my record validation query? Is ATF just incapable of making this comparison? I understand that I might be able to circumvent this by using a "Run server side script" test step rather than a "Record Validation" test step, but I'd like to avoid that if possible.

4 REPLIES 4

bbf3562
Kilo Guru

Can you provide screenshots of your ATF steps and show what you set up in Record Validation? That will help us investigate better.

Leonard Ambos
Mega Sage

Current ATF test steps (step 5 is the one that is failing):

find_real_file.png

 

Record Validation test step:

find_real_file.png

 

Keep in mind that the value that I had originally entered in the field (assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^) is not the value that currently appears in the field (assignment_group=feb04bb91b60b3c02c476356bd4bcb18^^u_functional_area=Benefits^^EQ). SNOW updated the value after I last updated the record.

Thanks for showing screenshots.

Here is what I suggest for best practice that you can update that later is to use 1 record validation instead of multiple record validations when validate the same record query. That will reduce steps.

1. Have you checked the Test Log to see what exactly the error was?

2. In step #5, can you verify by use Template.Template is not empty to see if the value exist or not?

3. Your script background showed output result, its print, "assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^" but in record validation you added "EQ" at the end that may not match which is why it failed?

Leonard Ambos
Mega Sage

I split the record validation out into multiple steps, as it was unclear to me which condition was resulting in failure otherwise. I added a step before #5 to ensure the record exists (the only operators available are "is", "is not" and "is anything").
find_real_file.png

 

This new step passes, but the assertion for the template.template value still fails:

find_real_file.png

 

The test log doesn't make it particularly clear in the step result what the issue is, as it doesn't show the value of the field, only that it didn't match the expected value:

find_real_file.png

 

Now, to be clear, the record log states that the record did not match conditions:

template.template=assignment_group=feb04bb91b60b3c02c476356bd4bcb18^^u_functional_area=Benefits^^EQ^EQ

 

That is NOT the value that I am trying to test against. I am trying to test template.template against:

assignment_group=feb04bb91b60b3c02c476356bd4bcb18^u_functional_area=Benefits^

 

However, every time I add that value in the field for Record Validation, SNOW appears to overwrite it with:

assignment_group=feb04bb91b60b3c02c476356bd4bcb18^^u_functional_area=Benefits^^EQ

 

That is the core of my problem. I am not sure if the apparent overwrite is how SNOW is storing the value in the database, or if it's modifying the database value when it displays it to me.