Arnoud Kooi
ServiceNow Employee
ServiceNow Employee

A nice way to draw attention to a particular field is leveraging Highlighted values.
On both the developer portal and docs site there are guidelines on how to use this.

 

You should probably not overdo it, but I think it has more use cases than only for a priority field.

 

What I was missing was a comprehensive overview of the colors/styles it would actually render.

Because I could not find it, so I decided to make a script for it 🤓.

 

The result can be found below, rendered in both Light and dark themes.

Note that this is an OOB theme, results may vary for you.

 

Highlighted values2.png

 

To be sure how It looks in your environment, you can use the below script.

This adds a rule to the short_description task table and adds a dummy task to be able to preview the result.

Once this is done, add a personal list for the task table in your workspace with the criteria mentioned in the script.

 

 

 

//Not meant to move to production, best used in a sandbox environment or PDI
//First create a record in sys_highlighted_value
//Set field Table: Task and Field Short Description
//Copy sys_id of your record and replace value [FILL YOUR SYSID HERE] below
//Map the UX highlighted Value Config to the SOW Workspace and/or the Workspace of your choice
//Add a custom list to the table Task in your workspace and short description starts with: Highlighted value

var colors = this.getChoices('sys_highlighted_value_condition', 'color');
var variants = this.getChoices('sys_highlighted_value_condition', 'variant');
var idx = 0;
for (i = 0; i < colors.length; i++) {
    for (j = 0; j < variants.length; j++) {
        var grHv = new GlideRecord('sys_highlighted_value_condition');
        grHv.newRecord();
        grHv.setValue('highlighted_value', '[FILL YOUR SYSID HERE]');
        grHv.setValue('show_icon', true);
        grHv.setValue('color', colors[i]);
        grHv.setValue('variant', variants[j]);
        grHv.setValue('conditions', 'short_descriptionLIKE' + colors[i] + '-' + variants[j]);
        grHv.setValue('order', idx++);
        grHv.insert();

        var grTsk = new GlideRecord('task');
        grTsk.newRecord();
        grTsk.setValue('short_description', 'Higlighted value [' + ("00" + idx).slice(-3) + ']: ' + colors[i] + '-' + variants[j]);
        grTsk.setWorkflow(false);
        grTsk.insert();

    }
}


function getChoices(table, field) {
    var choices = GlideChoiceList.getChoiceList(table, field);
    var rtrn = [];
    for (var i = 0; i < choices.getSize(); i++) {
        var choiceValue = choices.getChoice(i).getValue();
        if (choiceValue)
            rtrn.push(choiceValue);
    }
    return rtrn;
}

 

Comments
Community Alums
Not applicable

Hi @Arnoud Kooi 

I have applied this and I am not able to see any difference in primary, tertiary or secondary variant.

One thing I have noticed is that if I try to see the highlighted value field I can not see it.

Please let me know if you know something about it.

Thanks

Version history
Last update:
‎08-28-2023 05:27 AM
Updated by:
Contributors