Using Set field value step not able to set condition field value in ATF

chiranjeevi thi
Tera Contributor

Hi all,

 

we have created one ATF scenario while doing that in a table there is one condition field it's type also condition. Using set field value step not able to set it. Can you please help me on this. is there any step to do it.

chiranjeevithi_0-1699454548930.png

 

1 REPLY 1

Shaqeel
Mega Sage

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. Create the second step and choose 'Form' ==> 'Open an Existing Record'

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

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

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

8. Complete the rest test steps according your requirement

 

 

Regards

Shaqeel || ATF Expert


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel