Creating ATF Test to Dynamically Pick Up the active group member from the assign group ?

ramuv
Tera Expert

Creating ATF Test to Dynamically Pick Up the active group member from the assign group ?

Scenario :  we are testing the incident state flow , when select the assignment  group , we need to  set the assigned to field value dynamically , who's active group member  with populate first name.

Note : i am getting below error

FAILURE: Failed to set field 'assignment_group' to value '46b9490da9fe1981003c938dab89bda3' because the reference is NOT valid

 

Note : assignment group dynamically setting .

 

Thanks

2 REPLIES 2

Shaqeel
Mega Sage

Hi @ramuv 

 

Could you please attached the screenshot of the step used?

 

Regards

Shaqeel


***********************************************************************************************************************
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

Shaqeel
Mega Sage

Hi @ramuv 

 

I got the answer of your question:

 

This Step configuration takes the group name as an input and passes an active user name and sysId to output variables.

Step Environment: Server Independent

Category: Server

Input Variables:

Output Variables:

  • Output String: Column Name = u_user_sysid, Type = String
  • Output String: Column Name = u_user, Type = String

Description Script:

function generateDescription(step) {
// the global variable 'step' represents the current glide record
var description = gs.getMessage("Retrieves an active user from the group : '{0}'",
step.inputs.u_assignment_group);
return description;
}
generateDescription(step);

Step execution script:

(function executeStep(inputs, outputs, stepResult, timeout) {
var assignGroup = inputs.u_assignment_group;
var sysId;
var user;
var rowCount;
var queryFilter = "user.active=true^user.emailISNOTEMPTY^group.name=" + assignGroup;


var MESSAGE_KEY_NO_DISPLAY_VALUE = "Failure: No active user in this group";
var MESSAGE_KEY_SUCCESS = "Success: user value is passed to the output variable";

function logic() {

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery(queryFilter);
gr.query();
rowCount = gr.getRowCount();
if (gr.next()) {
user = gr.getDisplayValue('user');
sysId = gr.user;
}
}

function passStep() {
outputs.u_user_sysid = sysId;
outputs.u_user = user;
stepResult.setOutputMessage(MESSAGE_KEY_SUCCESS);
stepResult.setSuccess();

}

function failStep() {
stepResult.setOutputMessage(MESSAGE_KEY_NO_DISPLAY_VALUE);
stepResult.setFailed();

}

logic();
if (rowCount >= 1) {
passStep();
} else {
failStep();
}
}(inputs, outputs, stepResult, timeout));

 

Article: https://www.servicenow.com/community/developer-articles/atf-custom-step-configuration2-get-an-active...

 

Regards

 


***********************************************************************************************************************
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