on load client script to highlight vip user in service workspace operation

v-paulp
Tera Contributor

Hi 

We want to highlighted VIP user in the caller field in incident form and we have written a on load client script and it is working normal view but not working in service workspace operation.

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: "",
            fontWeight: "normal"
        });
        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,
            backgroundSize: "35px",
            paddingLeft: '30px'
        });
        callerField.setStyle({
            color: "red",
            fontWeight: "bold"
        });
    } else {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: "",
            fontWeight: "normal"
        });
    }
}
 
Do I need to write a different client script for service workspace operation?
 
Thanks
Pradip Paul
1 ACCEPTED SOLUTION

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @v-paulp 

 

https://www.servicenow.com/community/developer-forum/need-help-on-putting-vip-flag-on-form-and-list-....

 

 

The reason you do not see the VIP flag on either the form or list view in workspace is because this is an expected platform behavior.

Please go through this KB article - KB0794200 - How to display the VIP icon next to the Caller field

Only the background color field style is supported.

 

Additionally, ServiceNow doesnot recommends or support DOM manipulation:

We have a KB for this as well - DOM manipulation statements in onLoad client scritps fail after listV3 is enabled 

It's even mentioned in their product documentation : Client-side scripting design and processing

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @v-paulp 

 

https://www.servicenow.com/community/developer-forum/need-help-on-putting-vip-flag-on-form-and-list-....

 

 

The reason you do not see the VIP flag on either the form or list view in workspace is because this is an expected platform behavior.

Please go through this KB article - KB0794200 - How to display the VIP icon next to the Caller field

Only the background color field style is supported.

 

Additionally, ServiceNow doesnot recommends or support DOM manipulation:

We have a KB for this as well - DOM manipulation statements in onLoad client scritps fail after listV3 is enabled 

It's even mentioned in their product documentation : Client-side scripting design and processing

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG 

Thanks for reply.

But Background color is supported, How to configure that thing in service operation workspace  

Hi @v-paulp 

 

https://docs.servicenow.com/csh?topicname=now-platform-capabilities-rn-landing.html&version=latest

https://docs.servicenow.com/csh?topicname=highlight-list-fields.html&version=latest

https://docs.servicenow.com/csh?topicname=configure-highlighted-values.html&version=latest

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************