how to restrict the standard change creation when assignment group is inactive

RamcharanA
Tera Contributor

How to prevent standard change creation when assignment group is inactive.

1 ACCEPTED SOLUTION

Hello @RamcharanA, I'm not sure why you'd like to go for this approach when there are better approaches, highlighted earlier, available. Nevertheless, here are the SI and CS as asked:

- Script Include: ensure its client callable as depicted below

Nishant8_0-1748502826861.png

Here is the script to be used in SI

var TestRestrictChangeInactiveAssignedGroup = Class.create();
TestRestrictChangeInactiveAssignedGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	inactiveGroupCheck: function(){
		var assignedGroup = this.getParameter('sysparm_assignedGroup');
		var grGroup = new GlideRecord('sys_user_group');
		grGroup.get(assignedGroup);
		grGroup.addActiveQuery();
		grGroup.query();
		return grGroup.hasNext();
	},
    type: 'TestRestrictChangeInactiveAssignedGroup'
});

 - Client Script: its configured to run only for new record, if you wish to run it for existing Change too then remove the first if condition

Nishant8_1-1748503016442.png

Here is the script to be used

function onSubmit() {
	//Runs only for new record
    if (g_form.isNewRecord()) { // remove if condition here if to be run for update too
        var gaAssignedGroup = new GlideAjax('TestRestrictChangeInactiveAssignedGroup');
        gaAssignedGroup.addParam('sysparm_name', 'inactiveGroupCheck');
        gaAssignedGroup.addParam('sysparm_assignedGroup', g_form.getValue('assignment_group'));
        gaAssignedGroup.getXMLWait(); // doesn't work in portal
        var isActiveGroup = gaAssignedGroup.getAnswer();
        if (isActiveGroup === 'false') {
            g_form.addErrorMessage('Selected Group is inactive');
            return false;
        }
    }
}

 

Regards,

Nishant

View solution in original post

5 REPLIES 5

shun6
Giga Sage

Hi @RamcharanA ,

You can create Business rule to achieve your goal but more simple way is to configure "Reference qual condition" so that only active group is displayed at assignement group field.

 

Right click at "Assignment group" field and select Configure Dictionary.

shun6_0-1748440733480.png

Add filter condition like this. As a result, only active group can be selected at assignment group field. (inactive group is not displayed)

shun6_1-1748440776268.png

 

Thanks.

RamcharanA
Tera Contributor

Hi @shun6 i need to write script include and call that script in onSubmit client script do you have any suggestions please let me know.

Nishant8
Giga Sage

Hello @RamcharanA , There are couple of ways you can achieve this - proactively (updating the reference qualifier) or reactive (using Business Rule to prevent).

I'll suggest to use proactive approach so that no one can pick inactive group from the field, however sharing both the approaches below

1. Assignment Group dictionary change

Go to to Configure Dictionary and under Dictionary Overrides related list click New button and configure as below

Nishant8_0-1748446960242.png

2. Write Business rule on change_request table as below:

Nishant8_1-1748447204606.pngNishant8_2-1748447243187.png

 

 

Regards,

Nishant

 

Hi @Nishant8 i need to write script include and call that script in onSubmit client script do you have any suggestions please let me know.