Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Workaround for cannot find condition fields in [Set Field Value] or [Record Insert] in ATF - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Workaround for cannot find condition fields in [Set Field Value] or [Record Insert] in ATF
KB0752138

Workaround for cannot find condition fields in [Set Field Value] or [Record Insert] in ATF


1556 Views Last updated : Dec 5, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

There is a limit in ATF that using the Set Form Value or Record Insert test step on condition fields is not possible as ATF believes such fields are read-only.

The workaround for this limit is to skip the read-only UI validation by directly setting the value of the condition fields at the server side.

For example:

1. Create a new Test

2. Create the first step of the test and choose 'Server' ==> 'Run Server Side Script', make the step on the target table that your test works on

3. Use a script to set the 'condition' field. The following is an example of it:

(function(outputs, steps, stepResult, assertEqual) {
    // add test script here
  var testGr = new GlideRecord("<target table>");
  testGr.initialize();
  testGr.setValue("<condition field>", "<encoded query string>");
  testGr.setWorkflow(false);
  var newRecordSysId = testGr.insert();
  var newTestGr = new GlideRecord("<target table>");
  if (newTestGr.get(newRecordSysId)) {
        stepResult.setOutputMessage("Successfully inserted <target table> record");
        outputs.table = "<target table>";
        outputs.record_id = newRecordSysId;
        return true;
    } else {
        stepResult.setOutputMessage("Failed to insert <target table> record");
        return false;
    }

})(outputs, steps, stepResult, assertEqual);

4. Ensure to set mandatory fields as well in above script.

5. Create the second step and choose 'Form' ==> 'Open an Existing Record'

6. Setup the test step and make it open the record inserted by step 3 by using the reference selecting icon. Save the test step

7. Create the third step and choose 'Form' ==> 'Set Field Values'

8. Set the rest fields you need as your original plan

9. Complete the rest test steps according your requirement


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.