UI action

Anusha Medharam
Tera Contributor

I have created one UI action when login user click that UI action remove his name from assigned to  and state changes to new but when click UI action it asking please select records. Without selecting can we remove login user name from assigned field and state changes to new.

 

gr = new GlideRecord('sn_customerservice_case');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery("state","10");
gr.query();
var count =0;
while (gr.next()) {
    gr.assigned_to = '';
    gr.state = '1';
    count = count+1;
    gr.update();
}
if(count>0){
    gs.addInfoMessage(count+" Cases has been moved to New State and assigned to name removed too")
}else{
    gs.addInfoMessage("There are no Open Cases assigned to :"+gs.getUserDisplayName());
}
1 ACCEPTED SOLUTION

@Anusha Medharam i just checked it in my PDI .It OOB behaviour for list banner type UI action .

You have to select records and then proceed with the script .Otherwise it wont run the code.

 

Hope this helps 

Mark the answer correct if this helped you

Thanks

View solution in original post

17 REPLIES 17

Mohith Devatte
Tera Sage
Tera Sage

@Anusha Medharam Can you please post a screenshot of the pop up that you are getting to select records after clicking ?

 

Also is this UI action in list view or form view ?

hi

In list viewLIST.PNG

@Anusha Medharam Okay expected .Now can you post the complete script here of the UI action ?

 

did you use g_list API in UI action for the record selection ?

 

gr = new GlideRecord('sn_customerservice_case');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery("state","10");
gr.query();
var count =0;
while (gr.next()) {
    gr.assigned_to = '';
    gr.state = '1';
    count = count+1;
    gr.update();
}
if(count>0){
    gs.addInfoMessage(count+" Cases has been moved to New State and assigned to name removed too")
}else{
    gs.addInfoMessage("There are no Open Cases assigned to :"+gs.getUserDisplayName());
}