Creating ATF Test to Dynamically Pick Up Approver and Approve Submitted RITM

jmiskey
Kilo Sage

I am trying to create a somewhat "dynamic" ATF Test.  Basically, I want it to go out to the Service Portal, and make a specific Catalog Item Request.  This request will create a RITM that kicks off a workflow that has an Approval and a Task and then closes out.

So what I would like it to do is after I submit the request via the Service Portal, I would like to, on the ServiceNow side, is find the RITM (which we can dynamically do by capturing the ID of the submitted Catalog Item), and hopefully find the selected Approver for that RITM, and then Impersonate that Approver, and have that Approver open up that specific Approval, and approve it.  But I am not sure how to do that dynamically.

Here is what I have so far, which creates the request from the Service Portal side, but I am kind of stuck on the next steps. 

find_real_file.png

I know I could hard-code the Impersonation of the Approver (the workflow sets the Approver equal to the Manager), but I would like to figure out a way to dynamically determine the Approver from the submitted RITM.  Is that possible?

And then, how can we get to the correct Approval record to approve?

Thanks

 

1 ACCEPTED SOLUTION

Gerald Onyia
Kilo Guru

Question... how do you know who the Approval Task is supposed to go to? Is it the Requestor's Manager? Or is it a member of an Assignment Group for the Catalog Item?

 

Requestor Manager Scenario - Use a 'Create User' step above your Requestor's 'Create User' step to create a manager called "Joe Manager". Do not impersonate. Then in your current Step 2 (new Step 3), reference the 'Manager' field to Manager 'Create User' step. Once the Request is submitted:

  1. Use the 'Record Query' step in the Request Item table to query the Requested Item whose 'Request' is (reference 'Order a Catalog Item' step)
  2. Impersonate the (reference Manager 'Create user' step)
  3. Then use another 'Record Query' in the Approval table to query the Approval whose 'Approval For' is (reference RITM 'Record Query' step)
  4. Use 'Open Existing Record' step to open (reference Approval 'Record Query')
  5. Use 'Click UI Action' step to click Approve, and done

 

Assignment Group Scenario - Use a 'Create User' step above your Requestor's 'Create User' step to create a user called "Joe Approver", and assign the Group to that user. Do not impersonate. Once the Request is submitted:

  1. Use the 'Record Query' step in the Request Item table to query the Requested Item whose 'Request' is (reference 'Order a Catalog Item' step)
  2. Impersonate the (reference Approver 'Create user' step)
  3. Then use another 'Record Query' in the Approval table to query the Approval whose 'Approval For' is (reference RITM 'Record Query' step), and 'Approver' is (reference Approver 'Create User' step)
  4. Use 'Open Existing Record' step to open (reference Approval 'Record Query')
  5. Use 'Click UI Action' step to click Approve, and done

 

Hope this helps. Let me know if you have questions!

View solution in original post

12 REPLIES 12

Gerald Onyia
Kilo Guru

Question... how do you know who the Approval Task is supposed to go to? Is it the Requestor's Manager? Or is it a member of an Assignment Group for the Catalog Item?

 

Requestor Manager Scenario - Use a 'Create User' step above your Requestor's 'Create User' step to create a manager called "Joe Manager". Do not impersonate. Then in your current Step 2 (new Step 3), reference the 'Manager' field to Manager 'Create User' step. Once the Request is submitted:

  1. Use the 'Record Query' step in the Request Item table to query the Requested Item whose 'Request' is (reference 'Order a Catalog Item' step)
  2. Impersonate the (reference Manager 'Create user' step)
  3. Then use another 'Record Query' in the Approval table to query the Approval whose 'Approval For' is (reference RITM 'Record Query' step)
  4. Use 'Open Existing Record' step to open (reference Approval 'Record Query')
  5. Use 'Click UI Action' step to click Approve, and done

 

Assignment Group Scenario - Use a 'Create User' step above your Requestor's 'Create User' step to create a user called "Joe Approver", and assign the Group to that user. Do not impersonate. Once the Request is submitted:

  1. Use the 'Record Query' step in the Request Item table to query the Requested Item whose 'Request' is (reference 'Order a Catalog Item' step)
  2. Impersonate the (reference Approver 'Create user' step)
  3. Then use another 'Record Query' in the Approval table to query the Approval whose 'Approval For' is (reference RITM 'Record Query' step), and 'Approver' is (reference Approver 'Create User' step)
  4. Use 'Open Existing Record' step to open (reference Approval 'Record Query')
  5. Use 'Click UI Action' step to click Approve, and done

 

Hope this helps. Let me know if you have questions!

In reference to Gerald's suggestions, I am successfully using his method to locate the approval records.  (After submitting order, query to find RITM using the created REQ, then another query to find approvals using that RITM.)

I have had difficulty, though, with the next steps.  When ATF opens the approval form with the correct approval record, the command buttons are not visible, so my attempt to use the UI Action under the approval button is failing.

I have not had time to trouble shoot this issue, so could not tell you what might be causing it.

 

So you are opening the Approval record, but you are most likely opening the record as someone who isn't the actual approver. You can follow my steps to create an approver, and impersonate that approver. Be sure to have your 'Record Query' step for the Approval record include the 'Approval For' and 'Approver' fields. That way, you yield only one correct record, and be sure to impersonate the 'Approver'. If all still doesn't work, respond with a screenshot of your Steps, and I'll check it out.

Yes, the Approver is the Requestor's Manager (mentioned that quickly in passing just below my image above, sorry if I wasn't clear). 

I followed your steps, and it worked perfectly!  Thank you very much!

Now, I will see if I can figure out how to do the Task part.  If not, I may be back with another question.  But I am hoping the techniques you showed me here give me some good clues on how to do that too.