ATF test how to open a related list record using ATF

Meroda Gezahegn
Tera Contributor

I want to test that the related list record is opening correctly and validating the values using ATF but both the 'Validate Record in the List' and 'Open a Record in List' test steps are failed basically when I try to configure the steps  the dot walking is not even bringing the data correctly.

in my case I am using incident form and approval table as related list and here I want to open the approval record using ATF

Remember that I am not trying to test the existing record but a record which is generated in a flow that means I do have a flow when something changes the approval request is going and the record under the approval is created and I want to open the newly created record using ATF related list test steps

1 ACCEPTED SOLUTION

@Meroda Gezahegn , Thanks for the information. Got it now. In this case you can try with first Run server side script step  with below code.

Note:

1) Ensure you give valid step sys_id i.e. the sys_id of step which submits the incident.

2) Ensure in the next step you use Impersonate User Step and Select the output of this Run Server Side Script step i.e. record_id.

(function(outputs, steps, params, stepResult, assertEqual) {
   

var incRecordSysId = steps('sys_id_of_step').record_id; // give here the step sys_id for submit form of incident
// Get incident's assigned to 's manager
var gr = new GlideRecord("incident");
gr.addQuery('sys_id', incRecordSysId);  
gr.query();
if(gr.next()) {

var assigned_to_user = gr.assigned_to;

var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', assigned_to_user);

grUser.query();

if(grUser.next()){

outputs.table = 'sys_user';

outputs.record_id = grUser.manager;

stepResult.setOutputMessage("Incident Assigned to manager found " + grUser.manager);

stepResult.setSuccess();

return true;

}

else{

stepResult.setOutputMessage("Failed to find right user");

stepResult.setFailed();

return false;

}
}
})(outputs, steps, params, stepResult, assertEqual);
 
Hope it helps. Kindly mark helpful/accepted if it assists you.
Regards,
Priyanka Salunke.

View solution in original post

8 REPLIES 8

Priyanka_786
Tera Guru
Tera Guru

@Meroda Gezahegn ,

 

Do you have used open existing record step before these two list steps? It is required to be form opened before validating or opening record in related list.

Need more details on your ATF steps configured to debug  issue with dot walking for data. You can use debug feature of ATF.

There is another way to achieve this approval scenario by using below steps in case if it is not working after checking above.

1. Impersonation step- Impersonate with approver

2. Record query step-  on table sysapproval_approver. Pass Approver user in Approver field and in Approving field your incident record (from the step you are getting)

3. Open an existing record step- On sysapproval_approver table pass above record query step Id.

4. Set field values step- (Approval state and comments if required)

5.  Save form step

Hope it helps. Kindly mark helpful/accepted if it helps you.

Regards,

Priyanka Salunke

the problem is just I can not impersonate the approver because the approver is dynamic. The approver is the assigned to field value's manager So I want to test the approver is exactly the assigned to field value's manager. But when I try to dot_walk to get the manager from the approval table to the user table which is not working 

to make clear more I am on approval table and go to the incident table assigned to field and go to user table and get the user manager value on ATF test step

@Meroda Gezahegn , Thanks for the information. Got it now. In this case you can try with first Run server side script step  with below code.

Note:

1) Ensure you give valid step sys_id i.e. the sys_id of step which submits the incident.

2) Ensure in the next step you use Impersonate User Step and Select the output of this Run Server Side Script step i.e. record_id.

(function(outputs, steps, params, stepResult, assertEqual) {
   

var incRecordSysId = steps('sys_id_of_step').record_id; // give here the step sys_id for submit form of incident
// Get incident's assigned to 's manager
var gr = new GlideRecord("incident");
gr.addQuery('sys_id', incRecordSysId);  
gr.query();
if(gr.next()) {

var assigned_to_user = gr.assigned_to;

var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', assigned_to_user);

grUser.query();

if(grUser.next()){

outputs.table = 'sys_user';

outputs.record_id = grUser.manager;

stepResult.setOutputMessage("Incident Assigned to manager found " + grUser.manager);

stepResult.setSuccess();

return true;

}

else{

stepResult.setOutputMessage("Failed to find right user");

stepResult.setFailed();

return false;

}
}
})(outputs, steps, params, stepResult, assertEqual);
 
Hope it helps. Kindly mark helpful/accepted if it assists you.
Regards,
Priyanka Salunke.

It works thank you so much