How to Hide Particular Activity Set if logged in user is the manager of the subject Person

Veer
Kilo Sage

Hello @community 

I would like to hide an activity set from journey details page when loggedin user is the manager of the LE case.
I am aware of the checkboxes what we have on the activity configuration for display for opened for and display for subject person, but I am looking beyond that where we can alter the script include or widget code in order to achieve it.

Veer_0-1769278490965.png

 

1 REPLY 1

AnkaRaoB
Giga Guru

Hi @Veer 

 

In HR Lifecycle Events (Journeys), activity sets (stages) shown on the Journey Details page are rendered by a Service Portal widget.
Out-of-the-box configuration options such as Display for Opened For and Display for Subject Person do not support conditional visibility based on user relationships (for example, when the logged-in user is the manager of the LE case).

To meet this requirement, the recommended approach is to filter activity sets in the widget’s server script, ensuring the stage is never sent to the UI when the logged-in user is the manager.

Business Requirement

  • If the logged-in user is the manager of the Opened For user, hide a specific activity set (for example: Finalize Separation).
  • All other users (Employee, HR, Admin) should continue to see the activity set.
  • This approach avoids UI/CSS hacks, respects security boundaries, and remains upgrade-safe when the widget is cloned.

Implementation as follow

Clone the Journey Details Service Portal widget (do not modify OOB).

  1. Add logic in the widget Server Script to:
    • Identify the LE case
    • Check whether the logged-in user is the manager
    • Exclude the targeted activity set from the returned data

Widget Server Script

(function () {

 

    var leCaseId = input.sys_id;

    var leCaseGR = new GlideRecord('sn_hr_le_case');

    if (!leCaseGR.get(leCaseId)) {

        return;

    }

 

    // Check if logged-in user is the manager of the Opened For user

    var isManager = gs.getUserID() == leCaseGR.opened_for.manager.toString();

 

    data.stages = [];

 

    var stageGR = new GlideRecord('sn_hr_le_activity_set');

    stageGR.addQuery('le_case', leCaseId);

    stageGR.query();

 

    while (stageGR.next()) {

 

        // Hide specific activity set for manager

        if (isManager && stageGR.name == 'Finalize Separation') {

            continue;

        }

 

        data.stages.push({

            name: stageGR.name.toString(),

            sys_id: stageGR.sys_id.toString(),

            state: stageGR.state.toString()

        });

    }

 

})();

 

If this response helps you solve the issue, please mark it as Accepted Solution.