Issue In business rule

SAM321
Tera Contributor

Hi all, I have issue in one before query business rule. The issue is that whenever a user click and open any incident it is redirecting to a particular incident . The is issue in native instance as well as the agent workspace. But the same business rule is used in production instance there its working fine. The issue is in UAT instance. Checked with the update versions between instance everything is same .

5 REPLIES 5

Satishkumar B
Giga Sage
Giga Sage

Hi @SAM321 

 

  • Review Business Rule Conditions: Check the conditions and script of the Before Query Business Rule in the UAT instance to ensure it matches the production setup.
  • Compare Business Rule Scripts: Ensure that the script and logic in the UAT instance are identical to those in production.
  • Check for Customizations: Look for any additional customizations or modifications in UAT that might affect the behavior.

 

…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

 

SAM321
Tera Contributor

Hi @Satishkumar B yes I compared everything in UAT and PROD.. Everything is same in UAT and PROD. But the issue is still only in UAT.  In that BR when  I commntd(//) particular part and checked  in UAT then it is normal but i need that query condition. But in PROD the same script is used no issue.

Mark Manders
Mega Patron

Can you share your BR and what part you commented out, so we can see what could be the issue? Also: check on differences between the instances on the users you are looking at.
Next to that: check on other logic that is not the same, because you are focussing on the BR, but it could be something else that is different.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders  Below is the before query BR i shared:   that part is commented.

(function executeRule(current, previous /*null when async*/ ) {
    if (!(gs.action.getGlideURI().toString().indexOf('l_const') > -1)) { // if not from portal

        if (gs.action.getGlideURI().toString().indexOf('sysparm_view=ess') > -1) { // showing all tickets raised by user in self service view including SHR & CHR
                current.addEncodedQuery('caller_id='+gs.getUserID());
        } else { // works for other than Self service view

            var final_query = '';
            var ltc_inc_query = '',
                chr_ic = '',
                shr_ic = '',
                chr_central = '',
                shr_central = '';

            if (gs.hasRole('l_incident_admin')) {
               ltc_inc_query = 'categoryINe,hard,networking,email,login,copiers,security,l3_itinfra_services'; //ltc_incident_admin role access for all LTC incidents (Infra, EIP, ILMS)
            } else {
                var arrayUtil = new ArrayUtil();
                var my_grps = gs.getUser().getMyGroups();
                var my_arr_grps = arrayUtil.convertArray(my_grps);
                if (my_arr_grps.length > 0) {
                    var grps_gr = new GlideRecord('sys_user_group');
                    grps_gr.addEncodedQuery('parent=b203ce8987c3cd109f57cbb50cbb35cb^ORparent=3203ce8987c3cd109f57cbb50cbb35c8^ORparent=15848e51874d4e10fc7a65b50cbb359f^ORparent.parent=b203ce8987c3cd109f57cbb50cbb35cb^ORparent.parent=3203ce8987c3cd109f57cbb50cbb35c8^ORparent.parent=15848e51874d4e10fc7a65b50cbb359f^sys_idIN' + my_arr_grps);
                    grps_gr.query();
                    if (grps_gr.getRowCount() > 0) {
                        l_inc_query = 'categoryINe,hard,networking,email,login,copiers,security,l3_itinfra_services'; //Access for agent part of groups for all L incidents (Infra, EIP, ILMS)
                    }
                }
            }

            // //CHR
            // var sys = JSON.parse(gs.getProperty('module.data.segregation'));
            // for (var key in sys.CHR) {
            //     var grps = [];
            //     grps = sys.CHR[key].group_ids;
            //     for (var i = 0; i < grps.length; i++) {
            //         if (gs.getUser().isMemberOf(grps[i])) {
            //             if (key == 'Central Level') {
            //                 chr_central = 'category=chr';
            //             }
            //             if (key == 'IC Level') {
            //                 chr_ic = 'category=chr^caller_id.company=' + gs.getUser().getCompanyID();
            //             }
            //         }
            //         if (chr_central != '' || chr_ic != '')
            //             break;
            //     }
            //     if (chr_central != '' || chr_ic != '')
            //         break;
            // }

            // //SHR

            // for (var key1 in sys.SHR) {
            //     var grups = [];
            //     grups = sys.SHR[key1].group_ids;
            //     for (var j = 0; j < grups.length; j++) {
            //         if (gs.getUser().isMemberOf(grups[j])) {
            //             if (key1 == 'Central Level') {
            //                 shr_central = 'category=shr';
            //             }
            //             if (key1 == 'IC Level') {
            //                 shr_ic = 'category=shr^caller_id.company=' + gs.getUser().getCompanyID();
            //             }

            //         }
            //         if (shr_central != '' || shr_ic != '')
            //             break;
            //     }
            //     if (shr_central != '' || shr_ic != '')
            //         break;
            // }

            // if (l_inc_query != '') { // Access to infra,eip,ilms incidents
            //     final_query = l_inc_query;
            // }

            // if (chr_central != '') { // if part of central CHR group - access to all CHR incidents
            //     if (final_query != '') {
            //         final_query = final_query + '^NQ' + chr_central;
            //     } else {
            //         final_query = chr_central;
            //     }
            // }

            // if (chr_central == '' && chr_ic != '') { // if only part of CHR IC group - access to only respctive IC CHR Incidents
            //     if (final_query != '') {
            //         final_query = final_query + '^NQ' + chr_ic;
            //     } else {
            //         final_query = chr_ic;
            //     }
            // }

            // if (shr_central != '') { // if part of central SHR group - access to all SHR incidents
            //     if (final_query != '') {
            //         final_query = final_query + '^NQ' + shr_central;
            //     } else {
            //         final_query = shr_central;
            //     }
            // }

            // if (shr_central == '' && shr_ic != '') { // if only part of SHR IC group - access to only respctive IC SHR Incidents
            //     if (final_query != '') {
            //         final_query = final_query + '^NQ' + shr_ic;
            //     } else {
            //         final_query = shr_ic;
            //     }
            // }
            if (final_query != '') {
       
                current.addEncodedQuery(final_query);
            }
        }

    }

})(current, previous);