Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

HR Agent Workspace - Add Direct Reports and its popover to At a glance

jiral
Giga Sage

In the old HR workspace, the Org Information was part of its OOB configuration, but in the new HR Agent Workspace it's a component that you had to create yourself. Detailed below are the steps on how this can be accomplished.

 

1. Update the hr_atAGlanceUIBUtils script includes

 

var hr_atAGlanceUIBUtils = Class.create();
hr_atAGlanceUIBUtils.prototype = Object.extendsObject(hr_atAGlanceUIBUtilsSNC, {

    initialize: function() {
        hr_atAGlanceUIBUtilsSNC.prototype.initialize.apply(this, arguments);
    },

    /**
     * Get the direct reports of a user.
     * 
     * @Param {String} userSysId - The sys_id of the user.
     * @return {Array} An array of direct reports.
     */
	getDirectReports: function(userSysId) {
		var directReports = [];
		var gr = new GlideRecord('sn_hr_core_profile');
		gr.addQuery('user.manager.sys_id', userSysId);
		gr.addQuery('user.active', true);
		gr.orderBy('user');
		gr.query();
		while (gr.next()) {
			var report = {
				value: gr.getValue('sys_id'),
				displayValue: gr.getDisplayValue('user'),
				email: gr.getValue('user.email'),
				department: gr.getDisplayValue('user.department'),
				position: gr.getDisplayValue('position'),
				labelvaluestacked: []
			};

			var labelvaluestacked = [];

			// Position
			var positionLabel = gr.getElement('position').getLabel();
			var positionValue = gr.getDisplayValue('position');
			var positionDetails = {
				label: positionLabel,
				value: {
					type: "string",
					value: positionValue
				}
			};
			labelvaluestacked.push(positionDetails);


			// Department
			var departmentLabel = gr.getElement('user.department').getLabel();
			var departmentValue = gr.getDisplayValue('user.department');
			var departmentDetails = {
				label: departmentLabel,
				value: {
					type: "string",
					value: departmentValue
				}
			};
			labelvaluestacked.push(departmentDetails);

			// Email
			var emailLabel = gr.getElement('user.email').getLabel();
			var emailValue = gr.getDisplayValue('user.email');
			var emailDetails = {
				label: emailLabel,
				value: {
					type: "text-link",
					href: "javascript:void(0)",
					underlined: true,
					label: emailValue,
					link: "javascript:void(0)"
				}
			};
			labelvaluestacked.push(emailDetails);

			report.labelvaluestacked = labelvaluestacked;

			directReports.push(report);
		}
		
		// gs.info("Direct Reports: " + JSON.stringify(directReports));
		return directReports;
	},

	getAtAGlanceDetails: function(table, sysId, casesLimit, userSysId) {
		var recordGr = this._getRecordGr(table, sysId);

		// Get the value of opened_for (HR Case)or user (HR Profile) field as userSysId
		var userSysId = recordGr.getValue('opened_for') ? recordGr.getValue('opened_for') : recordGr.getValue('user');


		var data = hr_atAGlanceUIBUtilsSNC.prototype.getAtAGlanceDetails.call(this, table, sysId, casesLimit, userSysId);

		var userGr = this._getUserGr(userSysId);
		if (userGr && userGr.isValidRecord()) {
			data.directReports = this.getDirectReports(userGr.getUniqueValue());
		} else {
			data.directReports = [];
		}

		return data;
	},


    type: 'hr_atAGlanceUIBUtils'
});

 

 

2. Duplicate the Case SRP and set its order to an integer lower to set it as the default.

 

3. On the cloned Case SRP, head on to the "At a glance container" and create the Direct Reports container and its components under the Team Card container

jeffiral_0-1720769788276.png

 

jeffiral_1-1720769893961.pngjeffiral_2-1720769917672.pngjeffiral_3-1720769945507.png

 

4. Create the client state parameters:

jeffiral_0-1720770127557.png

 

6. Duplicate the Manager popover, and update the following component values:

jeffiral_6-1720770912857.png

 

jeffiral_5-1720770874675.png

 

Disable the HR SRP#AAG OPEN MANAGER PROFILE - Data resource Events and create a "Link to destination" event handler.

jeffiral_7-1720771085269.png

 

 

 

6. Go back to the Direct Reports container > Text Link 2 and create the following Events and map the values to the @item:

jeffiral_1-1720770243382.png

 

jeffiral_2-1720770262679.png

 

jeffiral_3-1720770281540.png

 

jeffiral_8-1720771209994.png

Select the popover from 6.

 

Final Result:

jeffiral_9-1720771340092.png

 

jeffiral_10-1720771359527.png

 

1 REPLY 1

Pamela Long
Tera Contributor

This was an excellent tutorial and it worked perfectly; thank you!