- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:29 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:40 AM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:45 AM
In list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 04:18 AM
Hello @Anusha Medharam ,
please follow below try and tested solution.
UI Action client Side
function cleanup() {
var ga = new GlideAjax('MA_SI_Execute_UI_Action');
ga.addParam('sysparm_name', 'CallScheduledJob');
ga.getXML(UpdateRecords); //async call
function UpdateRecords(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
alert("Updatation successfull");
setTimeout(function() {
location.reload(true);
}, 1000);
} else {
alert("No record Found");
}
}
}
Create Client callable Script Include:
var MA_SI_Execute_UI_Action = Class.create();
MA_SI_Execute_UI_Action.prototype = Object.extendsObject(AbstractAjaxProcessor, {
CallScheduledJob: function() {
try {
var gr = new GlideRecord('incident');
gr.addQuery('assigned_to', gs.getUserID());
gr.query();
while (gr.next()) {
gr.assigned_to = "";
gr.update();
}
return true;
} catch (ex) {
return false;
}
},
type: 'MA_SI_Execute_UI_Action'
});
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers!
Thanks and Regards,
Abhijeet Pawar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 05:32 AM
Hello @Anusha Medharam ,given script is working fine in list please check let me know if it is not fulfilling your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 04:47 AM
Hello @Anusha Medharam ,
Please try the below solution to avoid to the alert "No record selected". I tested the below solution and it is working correctly.
1. Create UI action.
UI Action script:
function removeAssignedTo() {
// gs.addInfoMessage(" Cases has been moved to New State and assigned to name removed too1");
var currentQuery = g_list.getQuery();
var ga = new GlideAjax('removeAssignedFromRecords'); //Call script include to parse execution id
ga.addParam('sysparm_name', 'removeAssignedTo'); // method name in script include
ga.addParam('sysparm_query', currentQuery); // parameter name
ga.getXMLAnswer(response);
function response(processResponse) {
if (processResponse > 0) {
alert(processResponse + " Cases has been moved to New State and assigned to name removed too");
} else {
alert("There are no Open Cases assigned to :" + g_user.userName());
}
}
}
script include:
Script Include Code:
var removeAssignedFromRecords = Class.create();
removeAssignedFromRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
removeAssignedTo: function() {
var query = this.getParameter('currentQuery');
var gr = new GlideRecord('incident');
gr.addEncodedQuery(query);
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery("state", "2");
gr.query();
var count = 0;
while (gr.next()) {
gr.assigned_to = '';
gr.state = '1';
count = count + 1;
gr.update();
}
return count.toString();
},
type: 'removeAssignedFromRecords'
});
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 05:26 AM
I need UI action only list view. Is this work in LIST View