CHEKING FOR INACTIVE GROUP FOR MAINTANCE TABLES

pavankumars3585
Tera Contributor

pavankumars3585_0-1770618548179.png

WHEN THE END USER SELECTS ACTION TYPE AS INACTIVE THE SELECTED GROUP HAS TO CHECK IN THE 5 MAINTENANCE TABLES FOR THE GROUP AND IF SELECTED GROUP HAS STILL HAVE SOME ACTIVE RECORDS THEN IT SHOULD AN ALERT LIKE(" the user first to remove the routings")

4 REPLIES 4

pavani_paluri
Tera Guru

Hi @pavankumars3585 ,

 

We can achieve this using client script and script include. Trigger the client script when the Action Type field changes to “Inactive.” Call a Script Include or GlideAjax to check the group’s status in the 5 tables.

 

If you can provide me with the names of the five tables along with a script, I’ll be able to help with the exact coding.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P


 

script include : 

checkInactiveGroup: function() {

var groupId = this.getParameter('sysparm_group_id');
gs.info('groupidis:' + groupId);

// All 5 maintenance tables with assignment group field
var tables = [ { table: 'u_rbis_maintenance', field: 'u_assigned_group' },
{ table: 'u_rbis_application_enhancement_maintain', field: 'u_assigned_group' },
{ table: 'u_ad_lgm_app_enhancement_request_maintain_data', field: 'u_support_group_name' },
{ table: 'u_corp_shared_application_support', field: 'u_routing_information' },
{ table: 'u_lgm_ihm_application_support', field: 'u_assignment_group' }
];

for (var i = 0; i < tables.length; i++) {

var gr = new GlideRecord(tables[i].table);
gr.addQuery(tables[i].field, groupId);
gr.addQuery('active', false); // inactive record
//gr.setLimit(1);
gr.query();

if (gr.hasNext()) {
gs.info('found:' + tables[i].table);
return 'true'; // Found inactive usage
}
}

return 'false';

},

client script :

var actionType = g_form.getValue('sngrp_action_type');
var groupId = g_form.getValue('sngrp_select_group');

if (actionType == 'inactive') {

var ga = new GlideAjax('ADRequestUtils');
ga.addParam('sysparm_name', 'checkInactiveGroup');
ga.addParam('sysparm_group_id', groupId);

ga.getXMLAnswer(function(answer) {
alert(groupId);
alert(answer);
if (answer === 'true') {
g_form.showFieldMsg(
'This assignment group is already inactive and exists in one of the maintenance tables.',
'error'
);}
});
}
}

Ankur Bawiskar
Tera Patron

@pavankumars3585 

we don't know if your form is Record Producer or Catalog Item.

Your requirement is not clear.

We didn't get what you meant by Maintenance tables etc

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

pavankumars3585
Tera Contributor

Hi Ankur .  The form is a catalog item and maintenance tables  means Routing tables