I need flag duplicate field values in a table using styles

Ashmit_Tyagi
Tera Contributor

I need to flag the the duplicate field values in a table with a red dot using field style, I tried using script include to write custom query but it flagging all the fields.

1 ACCEPTED SOLUTION

sejal1107
Tera Guru

Hi 

Please try adding one parameter in the function 

I have tried for incident short description field

 

var DuplicateShortdescription = Class.create();
DuplicateShortdescription.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getDuplicateValue: function(shortDesc) {
        var gr = new GlideRecord('incident');
        gr.query();
        var count = 0;
        while(gr.next()) {
            if (gr.short_description == shortDesc) {
				
                count++;
            }
        }
        if (count > 1) {
			
            return true;

        } else {
			
            return false;
        }

    },
    type: 'DuplicateShortdescription'
});

Screenshot 2024-09-02 at 8.05.27 PM.pngScreenshot 2024-09-02 at 8.05.39 PM.png

Please check and Mark Helpful and Correct if it really helped you.
Thanks & Regards
Sejal Chavan

View solution in original post

2 REPLIES 2

sejal1107
Tera Guru

Hi 

Please try adding one parameter in the function 

I have tried for incident short description field

 

var DuplicateShortdescription = Class.create();
DuplicateShortdescription.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getDuplicateValue: function(shortDesc) {
        var gr = new GlideRecord('incident');
        gr.query();
        var count = 0;
        while(gr.next()) {
            if (gr.short_description == shortDesc) {
				
                count++;
            }
        }
        if (count > 1) {
			
            return true;

        } else {
			
            return false;
        }

    },
    type: 'DuplicateShortdescription'
});

Screenshot 2024-09-02 at 8.05.27 PM.pngScreenshot 2024-09-02 at 8.05.39 PM.png

Please check and Mark Helpful and Correct if it really helped you.
Thanks & Regards
Sejal Chavan

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

I would really suggest NOT doing this on field styles as it will add a lot of load on your list when it loads. 

It will scan the whole table for each record each time. 

-Anurag