Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to create an CAB definition with filter criteria using ATF

Latoya
Kilo Guru

Happy Monday

I am unable to find a way to set the change request addition condition for a CAB definition using ATF . Any ideas? I tried working around it but it is mandatory so the process is not working properly. Custom UI does not find it. (t is not an option in the set field values. I want to be able to add a request state criteria. There is a modified fields option but not sure what that does.


Thanks

1 ACCEPTED SOLUTION

Not applicable

Hi @Latoya ,

please find the below script for reference.

(function(outputs, steps, params, stepResult, assertEqual) {
    // add test script here
var testGr = new GlideRecord("cab_definition");
  //testGr.get(steps('5f2656eb47603d10a54e5d0f536d438d').record_id);
  testGr.initialize();
  testGr.setValue("change_condition", "typeINnormal,emergency^riskIN2,3^category=Network^ORcategory=Hardware^EQ");
  testGr.setWorkflow(false);
  var newRecordSysId = testGr.insert();
  var newTestGr = new GlideRecord("cab_definition");
  if (newTestGr.get(newRecordSysId)) {
        stepResult.setOutputMessage("Successfully inserted cab_definition record");
        outputs.table = "cab_definition";
        outputs.record_id = newRecordSysId;
        return true;
    } else {
        stepResult.setOutputMessage("Failed to insert cab_definition record");
        return false;
    }
})(outputs, steps, params, stepResult, assertEqual);

make sure to follow the below step as suggested by the article above.

HemantGoldar_0-1692105040596.png

 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as the correct answer and helpful, This may help other community users to follow the correct solution.**

 

View solution in original post

4 REPLIES 4

Not applicable

Hi @Latoya ,

please find the below support article which will help you to achieve your task.
Workaround for cannot find condition fields in [Set Field Value] or [Record Insert] in ATF 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as the correct answer and helpful, This may help other community users to follow the correct solution.**

Hi Thank you so much

Do you have an example of a script for the "insert here" that I can reference?

Not applicable

Hi @Latoya ,

please find the below script for reference.

(function(outputs, steps, params, stepResult, assertEqual) {
    // add test script here
var testGr = new GlideRecord("cab_definition");
  //testGr.get(steps('5f2656eb47603d10a54e5d0f536d438d').record_id);
  testGr.initialize();
  testGr.setValue("change_condition", "typeINnormal,emergency^riskIN2,3^category=Network^ORcategory=Hardware^EQ");
  testGr.setWorkflow(false);
  var newRecordSysId = testGr.insert();
  var newTestGr = new GlideRecord("cab_definition");
  if (newTestGr.get(newRecordSysId)) {
        stepResult.setOutputMessage("Successfully inserted cab_definition record");
        outputs.table = "cab_definition";
        outputs.record_id = newRecordSysId;
        return true;
    } else {
        stepResult.setOutputMessage("Failed to insert cab_definition record");
        return false;
    }
})(outputs, steps, params, stepResult, assertEqual);

make sure to follow the below step as suggested by the article above.

HemantGoldar_0-1692105040596.png

 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as the correct answer and helpful, This may help other community users to follow the correct solution.**

 

Latoya
Kilo Guru

@Community Alums  Thank you sooooooooooooo much. I was able to add the values I needed. Woot Woot!