Why the List Action was not working in my list in workspace?

Ramu6
Tera Contributor

Hi All,

Actually I have created one List UI action "Allocate Task", in the Catalog task table , so here i need two things

1) This Ui action was need to display only on list "Assigned to your team" not on the "Assigned to You " list

2)when we click on this Ui action ,the earliast catalog task (only one)was need to assigned to me , but it assigned all the catalog tasks to me, i put set limit as well but not working

 

Ramu6_0-1740645591115.pngRamu6_1-1740645611675.png

 

Please help me to complete this

 

Thanks

Ramu

17 REPLIES 17

@Ramu6 

print the count outside

try this

function assignToMe() {
    var count = '0';
    var rec = new GlideRecord('sc_task');
    rec.addNullQuery('assigned_to');
    rec.addQuery('state', 'IN', '1,2');
    rec.setLimit(2);
    rec.query();
    gs.addInfoMessage(gs.getMessage('Number of Records updated' + rec.getRowCount());
        if (rec.hasNext()) {
            while (rec.next()) {
                rec.assigned_to = gs.getUserID();
                rec.setWorkflow(false);
                rec.update();
            }
        } else {
            gs.addInfoMessage(gs.getMessage('No new tickets found!' + rec.sys_id));
        }
    }

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

@Ankur Bawiskar 

Thanks for the code.

Tried this, its printing like this, but still updating multiple records

Ramu6_0-1740996528177.png

 

@Ramu6 

not very sure then

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