Skip to content

Add a tool for pending approvals

Managers ask “What’s waiting for my approval?” and “Are any timesheets still waiting on me?”. PeopleSoft’s workflow puts the items routed to each user on their worklist, so the answer is already in PeopleSoft. This guide adds a tool that reads it, scoped to the signed-in user, and returns only what the answer needs.

You’ll build: the GET /approvals operation in ZZ_ASSISTANT_HR, and the list_pending_approvals tool.

Decision For this tool
Input None: the token identifies the user, and the API reads only their own worklist
Output A count for each type of approval, the oldest item’s date, and a link to approve them
Security ZZ_ASSIST_USER, like the other tools. A user with nothing waiting gets an empty list
Not in it Who submitted each item, or what it’s for, which the answer doesn’t need

Counts answer most questions managers ask, and keep other people’s details out of the conversation. If managers later need names, add them in a second version, limited to the items routed to the user.

  1. Map worklists to labels. Worklist names are technical, so create a small setup table, such as ZZ_APPR_TYPE, that maps each worklist your managers approve from to a label they recognize, such as Timesheets or Absence requests. Worklists that aren’t in it aren’t counted.

  2. Count the open entries. The operation’s application class counts the user’s worklist entries that are still open, with INSTSTATUS 0 (available) or 1 (selected), by label:

    Open approvals, with %UserId bound to :1
    SELECT T.ZZ_LABEL, COUNT(*), MIN(W.INSTAVAILABLEDTTM)
    FROM PSWORKLIST W, PS_ZZ_APPR_TYPE T
    WHERE W.OPRID = :1
    AND W.INSTSTATUS IN (0, 1)
    AND T.WORKLISTNAME = W.WORKLISTNAME
    GROUP BY T.ZZ_LABEL
    ORDER BY 3
  3. Add the link. Store the address of the page where managers approve, such as your approvals tile’s page, in a URL definition, such as ZZ_APPROVALS, and return it with the counts.

  4. Create the operation as the GET method of the root resource approvals in ZZ_ASSISTANT_HR, with OAuth 2.0 required, as in Build the first application service.

The operation’s summary and description become the tool’s description, which the LLM reads to decide when to call it. Say what it answers, what it returns, and what it doesn’t:

The operation's description
Count the approvals waiting for the signed-in user, by type,
with the date of the oldest item of each type. Use it for
questions about what the user needs to approve. It doesn't say
who submitted each item.

Then add the tool to tools.yaml, with its progress message, and restart the service:

tools.yaml (excerpt)
tools:
list_pending_approvals:
operation: GET /approvals
progress: Looking for approvals waiting on you

A manager asks “Is anything waiting for my approval?”:

  1. The LLM calls list_pending_approvals, with no arguments.

  2. PeopleSoft runs the operation as the manager, after checking their token and their ZZ_ASSIST_USER permission list, and returns:

    The result
    {
    "total": 7,
    "approvals": [
    { "type": "Timesheets", "count": 5,
    "oldest": "2026-09-18" },
    { "type": "Absence requests", "count": 2,
    "oldest": "2026-09-22" }
    ],
    "page": {
    "label": "Pending Approvals",
    "url": "https://hr.example.com/psc/ps/EMPLOYEE/HRMS/..."
    }
    }
  3. The Assistant answers:

    You have 7 items waiting for your approval: 5 timesheets, the oldest from 18 September, and 2 absence requests. You can approve them on the Pending Approvals page.

    In the chat, the page name links to the URL in the result.

  • The manager’s counts match what they see on the approvals page.
  • An employee with nothing waiting hears “Nothing is waiting for your approval”, not an error.
  • An approval type that’s missing from the answer means its worklist isn’t in ZZ_APPR_TYPE yet.
  • The audit log shows one call to list_pending_approvals, with no arguments.