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

@Debasis Pati 

Hope you are doing good.

Did my reply answer your question?

💡 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 

did you get a chance to check this?

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

Deepak Shaerma
Mega Sage

Hi @Debasis Pati 

For this you need to do the modifications in the OOTB Ui Action...(But not recommended as uses the parent table)
In Filter Navigator type: sys_ui_action.list
use filters as 
Name : Assign to me
Table : task
Workspace Form Button : Checked or True


Put condition : 

current.active && !current.assignment_group.nil() && gs.getUser().isMemberOf(current.assignment_group.toString()) && current.assigned_to != gs.getUserID()

 

DeepakShaerma_0-1766405717454.pngDeepakShaerma_1-1766405847551.png

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




 

Hello @Deepak Shaerma ,

in the task ui action in the oob script include  SOWITSMCommonUtils i have extended the function below and amended only to incident table

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());
        }
    },

my question is is this gonna affect the exiting functionality of other tables?
 



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