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

@Ankur Bawiskar 

Actually if i didn't put setLimit then it update all the records

@Ramu6 

if encoded query is wrong then GlideRecord will update all the records

So please do this to confirm if your logic is working fine

1) comment line 9

2) in line 10 give setLimit(5)

3) then use while instead of if at line 12

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 

Still the same, whatever in setLimit(), its bypassing that and updating every record

@Ramu6 

share your latest script here, not screenshot

did you check what row count you got for your query?

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 Here is the script

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();
    while (rec.next()) {
gs.addInfoMessage(gs.getMessage('Number of Records updated' + rec.getRowCount());
        rec.assigned_to = gs.getUserID();
        rec.setWorkflow(false);
        rec.update();
    }
    else {
         gs.addInfoMessage(gs.getMessage('No new tickets found!' + rec.sys_id));
    }
}
 
Here Row count is printing 1 only, but updating multiple records