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

Brad Bowman
Kilo Patron
Kilo Patron

Is the same working outside of SOW?

Yes, in SOW the color is not setting 

Ramz
Mega Sage

Hi ,

1.Put alert messages in Client script to know if the output is coming correctly :

Example:alert(response.bus)

 

or,

 

2.Write 2 onchange client script:

-One to set the value

-One to change colour onchange of the value -Also use g_form.getElement instead of g_form.getControl

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

Thanks,

 

Everything is working only the color is not setting