Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Hide INC category and subcategory based on users email id

Shruthi8
Tera Contributor

I have a requirement to hide categories and subcategories on incident form when users having particular email id who logged in. I have tried the below Script include and on load Client script, please correct it its wrong and a solution would be helpful.

Thanks in Advance

Shruthi

CS.pngSI.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Shruthi8 

why not use field level READ ACL for this?

you are not calling the correct function from GlideAjax, your syntax is wrong

Use this

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

    UserID: function() {
        var email = gs.getUser().getEmail();
        email = email.toString();
        if (email.toLowerCase().indexOf('@email.com.au') > -1)
            return true;
        else
            return false;
    },

    type: 'HideCategory'
});

onLoad

function onLoad(){
var gaa = new GlideAjax('HideCategory');
	gaa.addParam('sysparm_name', 'UserID');
	gaa.getXMLAnswer(function(answer){
if(answer.toString() == 'true)
g_form.removeOption('category', 'incident');
});

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Shruthi8 

why not use field level READ ACL for this?

you are not calling the correct function from GlideAjax, your syntax is wrong

Use this

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

    UserID: function() {
        var email = gs.getUser().getEmail();
        email = email.toString();
        if (email.toLowerCase().indexOf('@email.com.au') > -1)
            return true;
        else
            return false;
    },

    type: 'HideCategory'
});

onLoad

function onLoad(){
var gaa = new GlideAjax('HideCategory');
	gaa.addParam('sysparm_name', 'UserID');
	gaa.getXMLAnswer(function(answer){
if(answer.toString() == 'true)
g_form.removeOption('category', 'incident');
});

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader