Display VIP group in SOW

Jay80
Tera Contributor

Hi,

 

we have VIP groups, we need to show the VIP group name beside the requested for user in SOW when creating an Incident is it possible? if so how? we have similar set up for Native UI, i have attached the screenshot for same

1 REPLY 1

G Ponsekar
Giga Guru

Hi @Jay80 ,

 

Can you try with placeholder to display VIP group name beside Requested for field?

Create client callable Script include and client script to achieve this

Script Include: VIPGroupInfo

var VIPGroupInfo = Class.create();
VIPGroupInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    getVIPGroupNames: function() {
        var userId = this.getParameter('sysparm_user_id');
        var groupNames = [];

        if (JSUtil.nil(userId)) {
            return '';
        }

        var grMember = new GlideRecord('sys_user_grmember');
        grMember.addQuery('user', userId);
        grMember.query();

        while (grMember.next()) {
            // Assuming VIP groups contain 'VIP' in their name
            if (grMember.group.name.indexOf('VIP') > -1) {
                groupNames.push(grMember.group.name.toString());
            }
        }
        return groupNames.join(', ');
    },

    type: 'VIPGroupInfo'});

Client script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        // When the field is cleared, reset the placeholder        g_form.setFieldPlaceholder('requested_for', '');
        return;
    }

    // Check if the user is VIP. The VIP status is already on the user record.
    var isVIP = g_form.getReference('requested_for').vip;

    if (isVIP) {
        // Make a GlideAjax call to the Script Include
        var ga = new GlideAjax('VIPGroupInfo');
        ga.addParam('sysparm_name', 'getVIPGroupNames');
        ga.addParam('sysparm_user_id', newValue);
        ga.getXMLAnswer(function(answer) {
            if (answer) {
                var newPlaceholder = 'VIP Group(s): ' + answer;
                g_form.setFieldPlaceholder('requested_for', newPlaceholder);
            }
        });
    } else {
        // If the user is not VIP, clear any VIP-related placeholder        g_form.setFieldPlaceholder('requested_for', '');
    }
}

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP