Assign to me ui ation on incident table doesnt shows up if it is assigned to someone else

Debasis Pati
Tera Guru

Hello Everyone,
The assign to me ui action on service operation workspace doesn't shows up if it is assigned to someone else of the group i am already part of.
I want this should show if it is assgned to one of my group and not assigned to me then i want to show the button.

@Ankur Bawiskar  what all changes i should do also the OOb script include and canassignedtome() button doesn't have the script to hide why its getting hided?

Regards,
Debasis

3 ACCEPTED SOLUTIONS

Hi @Debasis Pati 

Yes, this script will break the "Assign to Me" functionality for all other tables
The button will disappear entirely for every module except Incident.

Use this script as it uses your custom logic for Incident, but preserves the Out-of-the-Box (OOB) strict logic for everything else.

canAssignToMe: function(current) {
    var currentTable = current.getTableName();
    var arrayUtil = new global.ArrayUtil();
    var allowedTables = ["problem", "incident", "change_request", "problem_task"];

    if (!arrayUtil.contains(allowedTables, currentTable))
        return false;
        
    if (!current.active && !current.isNewRecord())
        return false;
        
    if (!this._checkRolesForAssignment(currentTable))
        return false;
        
    if (!current.assigned_to.canWrite())
        return false;


    if (currentTable == 'incident') {
        // Hide if already assigned to ME
        if (current.assigned_to == gs.getUserID())
            return false;
            

        return current.assignment_group.nil() || gs.getUser().isMemberOf(current.assignment_group.toString());
    }

    if (!current.assigned_to.nil())
        return false;

    return current.assignment_group.nil() || gs.getUser().isMemberOf(current.assignment_group.toString());
},

Happy to help! If this resolved your issue, kindly mark it as the correct answer and Helpful and close the thread 🔒 so others can benefit too.

Warm Regards,

Deepak Sharma

Community Rising Star 2025




View solution in original post

Hello @Ankur Bawiskar  & @Deepak Shaerma ,

Updated the script include function to this.

canAssignToMe: function(current) {
    var currentTable = current.getTableName();
    var arrayUtil = new global.ArrayUtil();
    var allowedTables = ["problem", "incident", "change_request", "problem_task"];

    // Table filter
    if (!arrayUtil.contains(allowedTables, currentTable))
        return false;

    // Record must be active and not newly created (already saved)
    if (!current.active && !current.isNewRecord())
        return false;

    // Role check (assuming your function exists)
    if (!this._checkRolesForAssignment(currentTable))
        return false;

    // Must be able to write to assigned_to
    if (!current.assigned_to.canWrite())
        return false;

    // --- Incident-specific logic ---
    if (currentTable === 'incident') {
        // Only show for New(1) or In Progress(2)
        var state = parseInt(current.getValue('state'), 10);
        if (state != 1 && state != 2)
            return false;

        // Hide if already assigned to me
        if (current.getValue('assigned_to') === gs.getUserID())
            return false;

        // Check group membership and group emptiness
        var groupIsEmpty = current.assignment_group.nil();
        var userInGroup = !groupIsEmpty && gs.getUser().isMemberOf(current.getValue('assignment_group'));

        // Show when no assignment group (anyone can take) OR user is in the assignment group
        return groupIsEmpty || userInGroup;
    }

    // --- Non-incident tables ---
    // Hide if already assigned
    if (!current.assigned_to.nil())
        return false;

    // Show when no assignment group OR user is in the assignment group
    return current.assignment_group.nil() || gs.getUser().isMemberOf(current.getValue('assignment_group'));
},

so the script function will explicitly act different for as it was earlier and will work as we need for incident table.
correct me if i have done any mistake.

View solution in original post

@Debasis Pati 

looks fine to me

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

21 REPLIES 21

Ankur Bawiskar
Tera Patron

@Debasis Pati 

share what condition is there currently or what script include function is being called and what's the current condition, screenshots

Logically since the task is already assigned it will be hidden since some agent is already working on it

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Debasis Pati 

Logically speaking it makes sense to show button only in above cases

the function will return true if

-> if group is empty

OR

-> Logged in user is member of current group

But if you still require then I shared below approach

 

 

AnkurBawiskar_0-1766410564047.png

 

Update as this

Instead of updating the OOTB Script Include function simply update the condition in UI action

(new global.ArrayUtil().convertArray(gs.getUser().getMyGroups())).indexOf(current.assignment_group) > -1 && (current.state == 1 || current.state == 2) && current.assigned_to != gs.getUserID()

AnkurBawiskar_2-1766410931275.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hello @Ankur Bawiskar ,
I found this button is from the task this one is not showing up on the portal.

Link:
https://yourinstance.service-now.com/sys_ui_action.do?sys_id=8513fcd0773b301027aae297cd5a9968&syspar...

so what i did is the below is used script include in the ui action;

SOWITSMCommonUtils

i have added one function and extended it:

canAssignToMe: function(current) {
        var currentTable = current.getTableName();
        var arrayUtil = new global.ArrayUtil();
        var allowedTables = ["problem", "incident", "change_request", "problem_task"];
        if(currentTable =='incident'){
        if (!arrayUtil.contains(allowedTables, currentTable))
            return false;
        if (!current.active && !current.isNewRecord())
            return false;
        if (!this._checkRolesForAssignment(currentTable))
            return false;
        if (!current.assigned_to.canWrite())
            return false;
        if (current.assigned_to==gs.getUserID())
            return false;
        return current.assignment_group.nil() || gs.getUser().isMemberOf(current.assignment_group.toString());
        }
    },
as other tables are aslo involved will it affect them because this function is present inside "SOWITSMCommonUtilsSNC" script include so my solution is now working for incident table but i do not want to break the oob functionality for problem ,change or oither tables is it right approach?