Creating ATF Test to Dynamically Pick Up the active group member from the assign group ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 07:02 AM - edited 07-03-2023 10:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 12:47 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:41 AM
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:
- Input String: Column Name = u_assignment_group, Type = String
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));
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