- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 11:22 PM
I have tired creating a Ui action for updating records selected in the list view but it's not working, for these records selected records the field value should be updated +1, please help resolve the issue
UI action script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 12:34 AM
Hi @Prasad49 ,
update the ui action script
function executeAction() {
// Get the selected Sys IDs from the list view
var selectedSysIds = g_list.getChecked();
// Ensure there are selected records
if (selectedSysIds.length === 0) {
// g_form.addErrorMessage('No records selected.'); // g_form is not available on list
alert('No records selected.');
return;
} else {
alert("selected ids" + selectedSysIds);
// gs.log("selected ids" + selectedSysIds); log doesn't workin as this is client side
var ga = new GlideAjax('IncrementFieldValueScriptInclude');
ga.addParam('sysparam_name', 'incrementFieldValue');
ga.addParam('sys_ids', selectedSysIds); // Send selected Sys IDs
// ga.addParam('u_trigger', u_trigger); // u_trigger is not declared and not required as per your script include
ga.getXMLAnswer(function(response) {
// var message = response.responseXML.documentElement.getAttribute("answer");
// g_form.addInfoMessage(message); g_form is not available on list
alert(response);
g_list.refresh();
});
}
}
since you are using the UI action in form also it's better to go with alternative approach with
uncheck the client on ui action and replace the script
alternative UI action script
var triggerCount = current.getValue('u_trigger'); triggerCount = triggerCount ? parseInt(triggerCount) + 1 : 0; current.u_trigger = triggerCount; current.update();
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 12:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 12:34 AM
Hi @Prasad49 ,
update the ui action script
function executeAction() {
// Get the selected Sys IDs from the list view
var selectedSysIds = g_list.getChecked();
// Ensure there are selected records
if (selectedSysIds.length === 0) {
// g_form.addErrorMessage('No records selected.'); // g_form is not available on list
alert('No records selected.');
return;
} else {
alert("selected ids" + selectedSysIds);
// gs.log("selected ids" + selectedSysIds); log doesn't workin as this is client side
var ga = new GlideAjax('IncrementFieldValueScriptInclude');
ga.addParam('sysparam_name', 'incrementFieldValue');
ga.addParam('sys_ids', selectedSysIds); // Send selected Sys IDs
// ga.addParam('u_trigger', u_trigger); // u_trigger is not declared and not required as per your script include
ga.getXMLAnswer(function(response) {
// var message = response.responseXML.documentElement.getAttribute("answer");
// g_form.addInfoMessage(message); g_form is not available on list
alert(response);
g_list.refresh();
});
}
}
since you are using the UI action in form also it's better to go with alternative approach with
uncheck the client on ui action and replace the script
alternative UI action script
var triggerCount = current.getValue('u_trigger'); triggerCount = triggerCount ? parseInt(triggerCount) + 1 : 0; current.u_trigger = triggerCount; current.update();
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 02:45 AM
alternative UI action script is working, Thanks marking your response as helpful