Client script not working- isolate script is true and UI type is all in service operations workspace

SHALIKAS
Tera Guru

Client script not working- isolate script is true and UI type is all in service operations workspace
Following is the code

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading) {
        return;
    }
    if (!newValue || newValue == '') {
        g_form.setValue('u_medal_category', '');
        return;
    }

    var ga = new GlideAjax('highlight_medal_category');
    ga.addParam('sysparm_name', "getUserInfo");
    ga.addParam('sysparm_ci', newValue);
    ga.getXMLAnswer(function(answer) {
        var response = JSON.parse(answer);
        g_form.setValue('u_medal_category', response.bus);
        var medal = g_form.getControl('u_medal_category');
        if (response.bus == '1 - Gold') {
            medal.style.color = "red";
        } else if (response.bus == '2 - Silver') {
            medal.style.color = "orange";
        } else if (response.bus == '3 - Bronze') {
            medal.style.color = "green";
        } else {
            medal.style.color = "";
        }
    });
}
 
Script Include -
var highlight_medal_category = Class.create();
highlight_medal_category.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getUserInfo: function() {
        var service_ci = this.getParameter('sysparm_ci');
        var gr = new GlideRecord("cmdb_ci_service");
        gr.get(service_ci);
        var bus = gr.busines_criticality.getDisplayValue();
        var response = {};
        response.bus = bus;
        return JSON.stringify(response);

    },

    type: 'highlight_medal_category'
});
1 ACCEPTED SOLUTION

SHALIKAS
Tera Guru

For this I went to Highlighted Values under Workspace Experience. From there created a new highlighted value for Service Operations Workspace application. 

Now while creating the incident in SOW the color will not be visible but after submitting the incident the color will be visible.

This worked for me

View solution in original post

6 REPLIES 6

Hi ,

I came across this article. Unfortunately getControl or getElement will not work in workspace.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0855260

 

Please mark my answer helpful/correct if it resolved your query

Thanks

SHALIKAS
Tera Guru

For this I went to Highlighted Values under Workspace Experience. From there created a new highlighted value for Service Operations Workspace application. 

Now while creating the incident in SOW the color will not be visible but after submitting the incident the color will be visible.

This worked for me