Set vip flag on requested for field on REQ, RITM and SCTASK

Ken61
Giga Guru

I have a requirement to set vip tag for "Requested for" on REQ, RITM and SCTASK.

Similar functionality was customized with onchange client script on incident and it is working as expected.

The script was modified but not working for RITM,REQ and SCTASK. 

Below is the script. Can you assist in making the script works. I need this to be done with onchange client script.

function onChange(control, oldValue, newValue, isLoading) {
    var callerLabel = $('label.incident.caller_id');
    var callerField = $('sys_display.incident.caller_id');
    if (!callerLabel || !callerField)
        return;

    if (!newValue) {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
        return;
    }
    g_form.getReference('caller_id', vipCallerCallback);
}

function vipCallerCallback(caller) {
    var callerLabel = $('label.incident.caller_id').down('label');
    var callerField = $('sys_display.incident.caller_id');
    if (!callerLabel || !callerField)
        return;

    //check for VIP status
    if (caller.vip == 'true') {
        var bgPosition = "95% 55%";
        if (document.documentElement.getAttribute('data-doctype') == 'true')
            bgPosition = "5% 45%";

        callerLabel.setStyle({
            backgroundImage: "url(images/icons/vip.gif)",
            backgroundRepeat: "no-repeat",
            backgroundPosition: bgPosition,
            paddingLeft: '30px'
        });
        callerField.setStyle({
            color: "red"
        });
    } else {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
    }
}

 

Thank You. 

1 ACCEPTED SOLUTION

Ken61
Giga Guru

I was able to use below code to set vip for request form and use style to set vip on the sc_request table.

Thank You

function onChange(control, oldValue, newValue, isLoading) {

    var callerLabel = $('label.sc_request.requested_for');
    var callerField = $('sys_display.sc_request.requested_for');
    if (!callerLabel || !callerField)
        return;

    if (!newValue) {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
        return;
    }
    g_form.getReference('requested_for', vipCallerCallback);
}

function vipCallerCallback(caller) {
    var callerLabel = $('label.sc_request.requested_for').down('label');
    var callerField = $('sys_display.sc_request.requested_for');
    if (!callerLabel || !callerField)
        return;

    //check for VIP status
    if (caller.vip == 'true') {
        var bgPosition = "95% 55%";
        if (document.documentElement.getAttribute('data-doctype') == 'true')
            bgPosition = "5% 45%";

        callerLabel.setStyle({
            backgroundImage: "url(images/icons/vip.gif)",
            backgroundRepeat: "no-repeat",
            backgroundPosition: bgPosition,
            paddingLeft: '30px'
        });
        callerField.setStyle({
            color: "red"
        });
    } else {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
    }
}

View solution in original post

9 REPLIES 9

Hello @JoeSD 

I followed your steps above to create ae for requested for field. But it's still not working.

Below is the screenshot for the style record that was created.

Ken61_0-1715735909574.png

 

JoeSD
Tera Expert

Have you created the same style for RITM and SCTASK? And do you have the VIP flag checked for the users you are testing with?

I have created the same style for RITM and the vip flag has been checked for the caller using to test.

Are you populating the requested for field with the same user as the caller? 

Ken61
Giga Guru

I was able to use below code to set vip for request form and use style to set vip on the sc_request table.

Thank You

function onChange(control, oldValue, newValue, isLoading) {

    var callerLabel = $('label.sc_request.requested_for');
    var callerField = $('sys_display.sc_request.requested_for');
    if (!callerLabel || !callerField)
        return;

    if (!newValue) {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
        return;
    }
    g_form.getReference('requested_for', vipCallerCallback);
}

function vipCallerCallback(caller) {
    var callerLabel = $('label.sc_request.requested_for').down('label');
    var callerField = $('sys_display.sc_request.requested_for');
    if (!callerLabel || !callerField)
        return;

    //check for VIP status
    if (caller.vip == 'true') {
        var bgPosition = "95% 55%";
        if (document.documentElement.getAttribute('data-doctype') == 'true')
            bgPosition = "5% 45%";

        callerLabel.setStyle({
            backgroundImage: "url(images/icons/vip.gif)",
            backgroundRepeat: "no-repeat",
            backgroundPosition: bgPosition,
            paddingLeft: '30px'
        });
        callerField.setStyle({
            color: "red"
        });
    } else {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });
    }
}