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

Bert_c1
Kilo Patron

Seems the script references the incident table, maybe change that to specific table each client script is defined for "REQ, RITM and SCTASK".

@Bert_c1 

Thanks for responding.

I did made changes to the table and field on the client script. Below is my client sript for sc_request table.

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', vipCallerCallbackREQ);
}

function vipCallerCallbackREQ(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: ""});
	}
}

 But still not working. 

Hi,

 

I suggest you add 'alert(" callerLabel = " + callerLabel + ", callerField = " + callerField);' statements to your script. and the like withing your script to debug your logic. You have a reference to 

vipCallerCallbackREQ

 in the above but the function is 

function vipCallerCallbackREQ(caller) {

 

see what others suggest.

JoeSD
Tera Expert

You may be able to use a style for that field instead of a client script.

I was able to set up the following style for the opened_by field for the sc_task table:

JoeSD_0-1715733758736.png