Query to fetch Pending Goals from Employees profile
Summary:I have an employee who has created one goal but has not submitted it yet so I am unable to view that goal from my profile , I need to fetch the status of that goal which is not submitted along with the goal details.
Below is the Query I am using currently:
WITH ranked_goals AS ( SELECT papf.person_id, paam.assignment_id, hgm.measurement_id, hgpvl.goal_plan_name AS GOAL_PLAN_NAME, ppnf.display_name AS EMPLOYEE_FULL_NAME, papf.person_number AS PERSON_NUMBER, hla.town_or_city AS LOCATION_CITY, hla.country AS COUNTRY_CODE, ftv.territory_short_name AS COUNTRY_NAME, hg.goal_name AS GOAL_DESCRIPTION, hg.goal_version_type_code AS GOAL_VERSION_TYPE_CODE, TO_CHAR(hg.start_date, 'DD-MM-YYYY') AS GOAL_START_DATE, hg.status_code AS GOAL_STATUS, hg.goal_type_code, CASE -- PRIORITY 1: Rejected goals WHEN hg.approver_response_code = 'REJECTED' THEN 'Rejected' -- PRIORITY 2: Pending Approval (Submitted - waiting for approval) WHEN hg.goal_version_type_code = 'PENDING_APPROVAL' THEN 'Pending Approval' -- PRIORITY 3: Frozen goals (approved and locked) WHEN hg.goal_version_type_code = 'FROZEN' THEN 'Approved - Frozen' -- PRIORITY 4: Active approved goals WHEN hg.goal_version_type_code = 'ACTIVE' THEN 'Approved' -- PRIORITY 5: