Operation against file 'u_attribute' was aborted by Business Rule 'GQRM_Restrict Duplicate attribute

Sanchita02
Tera Contributor

I have a BR running to abort duplicate values on attribute table

This is giving me two error message and one info message. I have requirement to show only one error message mentioned in the script

Sanchita02_2-1729154591880.png

 

AND

It is giving info message as "attribute inserted" - but because of the below business rule the attribute is not getting inserted so i am not sure why this message is coming

 

 

Business Rule : Before Insert

 

(function executeRule(current, previous /*null when async*/ ) {
        var errorMessage = "";
        var attributeType = current.u_type_of_attribute;
        var attributeTitle = current.u_title;
        var attribute = new GlideRecord("u_attribute");
        attribute.query('u_member_firm', current.u_member_firm);
        attribute.query("u_application", current.u_application);
        attribute.query("u_type_of_attribute", current.u_type_of_attribute);
        if (attributeType == 'request_type' || attributeType == 'type_of_client') {
            attribute.query('u_title', attributeTitle);
        }
        attribute.query('u_active', 'true');
        attribute.query();
        if (attribute.next()) {
            errorMessage = "The new " + current.getDisplayValue('u_type_of_attribute') + ' attribute cannot be created, as there is an active attribute already present.';
            gs.addErrorMessage(errorMessage);
            current.setWorkflow(false);
            current.setAbortAction(true); 
        } else {
            return true;
        }

})(current, previous);
 

 

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

With this Business Rule inactivated, are any messages shown using the same test case?  Is the name of this Business Rule "GQRM_Restrict Duplicate attribute"?

@Brad Bowman  "Attribute inserted" message shown when deactivating this BR. Yes the name of br is "GQRM_Restrict Duplicate attribute"

 

The only thing I see about your script is that you don't really need the else block as that will happen anyway if a matching record on your custom table is found.  None of these message are out of box behavior, even on a custom table - there's not an '...inserted' info message or the longer error message, though that would be nice rather than the out of box behavior 'invalid insert' without a clue as to why.  You have some customization in your instance, so you'll have to check all Business Rules, Script Includes, and System UI Messages for what might be triggering these - you can search on the partial static text of each to make it easier.  Either setWorkflow(false) is being bypassed/ignored, or there's something other than another Business Rule running on insert of this table.