We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to verify whether the approval has been generated for the User's actual Manager through ATF

VasundharaS0455
Giga Contributor

When the User raise a Service Fulfillment Request through a given catalog Item, approval is generated for the User's Manager.

How can we verify whether the approval has been generated for the actual User's Manager or not.

I want to check through ATF.

4 REPLIES 4

SumanthDosapati
Mega Sage

@VasundharaS0455 

 

You can do Record Query on sysapproval_approver table with condition as user.manager to validate a approval.

This link should help you.

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

 

PoonkodiS
Mega Sage

Hi @VasundharaS0455 

Could you try the steps in your instance and share the feedback

PoonkodiS_0-1768948576208.png

Regards,

Poonkodi

PoonkodiS
Mega Sage

Sorry, Remove the step 9: Record query, i added it twice

VaishnaviK3009
Tera Guru

Hi @VasundharaS0455 !!

 

Step 1: Impersonate User

  • Use a test user who has a Manager field populated

Step 2: Submit Catalog Item

  • Use Submit a Catalog Item ATF step

  • Capture the RITM sys_id in a test variable (example: ritm_id)

Step 3: Run Server-side Script (Validation)

(function () {

    // Get RITM
    var ritmId = steps.ritm_id;
    var ritmGR = new GlideRecord('sc_req_item');
    ritmGR.get(ritmId);

    // Get Requested For user
    var userGR = new GlideRecord('sys_user');
    userGR.get(ritmGR.requested_for);

    // Get Manager
    var managerId = userGR.manager.toString();

    // Validate approval for manager
    var approvalGR = new GlideRecord('sysapproval_approver');
    approvalGR.addQuery('sysapproval', ritmId);
    approvalGR.addQuery('approver', managerId);
    approvalGR.addQuery('state', 'requested');
    approvalGR.query();

    if (!approvalGR.hasNext()) {
        throw 'Manager approval was not generated correctly';
    }

})();

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Associate Technical Consultant