VaranAwesomenow
Mega Sage

**Streamlining Life Cycle Event Analysis: A Game-Changing Script**

As anyone who has worked with life cycle events knows, analyzing the complex web of activity sets, activities, and audiences can be a daunting task. It's a process that can consume countless hours, draining productivity and energy. But what if there was a way to simplify this tedious process and free up more time for strategic thinking and growth?

We're excited to introduce a script that does just that. This innovative tool automates the identification of life cycle event information, presenting it in a clear and concise tab-separated format. Say goodbye to tedious manual analysis and hello to streamlined efficiency.

**The Challenge of Manual Analysis**

Manually analyzing life cycle events involves pouring over vast amounts of data, identifying patterns, and connecting the dots between activity sets, activities, and audiences. It's a task that requires immense attention to detail, a deep understanding of the data, and a healthy dose of patience. But even with the best intentions, human error can creep in, leading to inaccuracies and inconsistencies.

**The Power of Automation**

Our script changes the game by automating the analysis process, eliminating the risk of human error and freeing up valuable time for more strategic pursuits. With this tool, you can:

* Quickly identify key life cycle event information
* Easily analyze activity sets, activities, and audiences
* Present data in a clear and concise tab-separated format

**The Benefits of Automation**

By automating life cycle event analysis, you can:

* Save time and reduce the risk of burnout
* Increase accuracy and consistency in your data analysis
* Focus on higher-level thinking and strategy
* Make data-driven decisions with confidence

**Conclusion**

Life cycle event analysis doesn't have to be a tedious and time-consuming process. With our script, you can streamline your analysis, free up more time for growth and innovation, and make data-driven decisions with confidence. Try it out today and discover the power of automation for yourself!

 

Script :  Application scope : Human Resources: Lifecycle Enterprise

var audienceHash = {};
audienceHash = new sn_cd.RBReadAudience().getAudience();
var sDebug = 'Life cycle event summary' + "\n";
var leHash = {};
var grLE = new GlideRecord('sn_hr_le_type');
var leEnQuery = 'active=true';
grLE.addEncodedQuery(leEnQuery);
grLE.query();
while (grLE.next()) {
    getActivitySets(grLE.sys_id.toString());
}

printLeData();

function getActivitySets(leSysId) {
    var grASet = new GlideRecord('sn_hr_le_activity_set');
    var AsEnQuery = 'le_type=' + leSysId + '^active=true';
    grASet.addEncodedQuery(AsEnQuery);
    grASet.orderBy('display_order');
    grASet.query();
    while (grASet.next()) {
        var audienceString;
        var audienceArray = [];
        var audienceData = '';
        audienceString = grASet.audience;
        if (global.JSUtil.notNil(audienceString)) {
            audienceString = audienceString.toString();
            audienceArray = audienceString.split(",");
            if (audienceArray.length > 0) {
                for (var k = 0; k < audienceArray.length; k++) {
                    if (global.JSUtil.notNil(audienceHash[audienceArray[k]])) {
                        audienceData += audienceHash[audienceArray[k]] + "|";
                    }
                }
            }
        }

        if (audienceData != '') {
            leHash[grASet.le_type.title + "|" + grASet.title] = " Audience = " + audienceData;
        } else {
            leHash[grASet.le_type.title + "|" + grASet.title] = " No Audience";
        }
        getActivities(grASet.sys_id.toString());
    }
}

function getActivities(asSysId) {
    var grAct = new GlideRecord('sn_hr_le_activity');
    var AsEnQuery = 'activity_set=' + asSysId + '^active=true';
    grAct.addEncodedQuery(AsEnQuery);
    grAct.orderBy('display_order');
    grAct.query();
    while (grAct.next()) {
        var audienceString;
        var audienceArray = [];
        var audienceData = '';
        audienceString = grAct.audience;
        if (global.JSUtil.notNil(audienceString)) {
            audienceString = audienceString.toString();
            audienceArray = audienceString.split(",");
            if (audienceArray.length > 0) {
                for (var k = 0; k < audienceArray.length; k++) {
                    if (global.JSUtil.notNil(audienceHash[audienceArray[k]])) {
                        audienceData += audienceHash[audienceArray[k]] + "|";
                    }
                }
            }
        }
        if (audienceData != '') {
            leHash[grAct.activity_set.le_type.title + "|" + grAct.activity_set.title + "|" + grAct.title] = " Audience= " + audienceData;
        } else {
            leHash[grAct.activity_set.le_type.title + "|" + grAct.activity_set.title + "|" + grAct.title] = "No Audience";
        }
    }
}


function printLeData() {
    for (var obj in leHash) {
        sDebug += obj + "|" + leHash[obj] + "\n";
    }
}

gs.info(sDebug);
Script include : scope : Content Publishing
var RBReadAudience = Class.create();
RBReadAudience.prototype = {
    initialize: function() {},
    getAudience: function() {
        var audienceHash = {};
        var grAud = new GlideRecord('sn_cd_audience');
        grAud.query();
        while (grAud.next()) {
            var hrCriteriaCon = ' hr criteria:  ';
            if (grAud.audience_type.toString() == 'sn_hr_core_criteria') {
                hrCriteriaCon = this._getHrCriteria(grAud.audience_query.toString());
                audienceHash[grAud.sys_id.toString()] = grAud.name + "|*#|" + grAud.audience_type + "|*#|" + hrCriteriaCon;
            } else {
                audienceHash[grAud.sys_id.toString()] = grAud.name + "|*#|" + grAud.audience_type + "|*#|" + grAud.audience_query.toString();
            }
        }
        return audienceHash;
    },
    _getHrCriteria: function(hrCSysId) {
        var hrConString = '';
        var grHrConCriteria = new GlideRecord('sn_hr_core_m2m_condition_criteria');
        var hrConQuery = 'hr_criteria.sys_id=' + hrCSysId;
        grHrConCriteria.addEncodedQuery(hrConQuery);
        grHrConCriteria.query();
        while (grHrConCriteria.next()) {
            var grHrCon = new GlideRecord('sn_hr_core_condition');
            grHrCon.get(grHrConCriteria.hr_condition.sys_id.toString());
            if (grHrCon.active == true) {
                hrConString += grHrCon.condition + " user column =" + grHrCon.user_column.toString() + "*|*|";
            }
        }
        return hrConString;
    },

    type: 'RBReadAudience'
};
 
Sample output on OOB PDI instance.
 
Life cycle event summary
Test LE|AS1| Audience = Active Users|*#|sys_user|*#|active=true|
Test LE|AS1|AS1 A2|No Audience
Performance improvement plan (PIP)|Initiate PIP| No Audience
Performance improvement plan (PIP)|Initiate PIP|Inititate PIP activity container|No Audience
Performance improvement plan (PIP)|Initiate PIP|Review plan|No Audience
Performance improvement plan (PIP)|Initiate PIP|Discuss PIP and align on goals with Employee|No Audience
Performance improvement plan (PIP)|Initiate PIP|Scheduling coaching conversation with the manager|No Audience
Performance improvement plan (PIP)|Initiate PIP|Develop a plan|No Audience
Performance improvement plan (PIP)|Track Progress| No Audience
Performance improvement plan (PIP)|Track Progress|Track PIP activity container|No Audience
Performance improvement plan (PIP)|Track Progress|Schedule check-in with Employee to discuss progress|No Audience
Performance improvement plan (PIP)|Track Progress|Track employee progress|No Audience
Performance improvement plan (PIP)|Track Progress|Periodic review with HR|No Audience
Performance improvement plan (PIP)|Close PIP| No Audience
Performance improvement plan (PIP)|Close PIP|PIP assessment|No Audience
1 Comment