Exception

nameisnani
Mega Sage

Hi Team

 

While approving any thing we are getting this below error like this . 

SunilKumarPadh_0-1678071025081.png

Not only in KB where ever approval triggers 

SunilKumarPadh_1-1678071097063.png

 

 

Error Message

 

 

 

Error MessageException (ConversionError: The undefined value has no properties. (sys_script.68f636ad1b9f555075fbeb16624bcb75.condition; line 1)) occured while evaluating'Condition: current.document_id.cat_item.getDisplayValue() === "Sailpoint Access Request - Service Catalog" && current.wf_activity == '0d4af8ee1b2799907816c913604bcb3b'; Filter Condition: stateCHANGESTOapproved^ORstateCHANGESTOrejected^state_bindingISEMPTY^EQ' in business rule 'SP_SPNT_SNOW_INT_MLA_Approval_Manager' on sysapproval_approver: Knowledge: KB0010118 v0.02; skipping business rule

Error MessageException (ConversionError: The undefined value has no properties. (sys_script.cca58ec71ba31d907816c913604bcb6b.condition; line 1)) occured while evaluating'Condition: current.document_id.cat_item.getDisplayValue() === "Sailpoint Access Request - Service Catalog" && current.wf_activity == '4a2c798f1b631d907816c913604bcb6a'; Filter Condition: stateCHANGESTOapproved^ORstateCHANGESTOrejected^EQ' in business rule 'SP_SPNT_SNOW_INT_MLA_Approval_Manager_IW' on sysapproval_approver: Knowledge: KB0010118 v0.02; skipping business rule

Error MessageException (ConversionError: The undefined value has no properties. (sys_script.9d202dfd1b4b991075fbeb16624bcb62.condition; line 1)) occured while evaluating'Condition: current.document_id.cat_item.getDisplayValue() === "Sailpoint Access Request - Service Catalog"; Filter Condition: stateCHANGESTOapproved^ORstateCHANGESTOrejected^ORstateCHANGESTOcancelled^ORstateCHANGESTOnot_required^EQ' in business rule 'SP_SPNT_SN_INT_CreateWorkNoteOnRITM' on sysapproval_approver: Knowledge: KB0010118 v1.0; skipping business rule

 

 

 

 

For more Information 

 

Based on the error message these are BR's 

 

 

SunilKumarPadh_2-1678072081025.png

 

1.SP_SPNT_SNOW_INT_MLA_Approval_Manager

 

 

(function executeRule(current, previous /*null when async*/ ) {
	var currExex = '';
    var grItem = new GlideRecord('sc_req_item');
    grItem.get('sys_id', current.document_id);

	if(!gs.nil(grItem.x_sap_intidn_sailpoint_mla_current_level))
		currExec = global.JSON.parse(grItem.x_sap_intidn_sailpoint_mla_current_level);
	
   
	//add checks for Idn workflow skip
	
    //REJECT	
    if (current.state == 'rejected') {
		
        var grPendingApps = new GlideRecord('sysapproval_approver');
        grPendingApps.addQuery('document_id', current.document_id);
        grPendingApps.query();
        while (grPendingApps.next()) {

            if (grPendingApps.state == 'requested') {
                grPendingApps.state = 'not_required';
                grPendingApps.update();
            }
        }


        grItem.x_sap_intidn_sailpoint_mla_current_level = 'rejected';
        grItem.update();
    } else if (current.state == 'approved') {
        for (var i = 0; i < currExec.length; i++) {
            for (var j = 0; j < currExec[i].appList.length; j++) {

                if (current.sys_id == currExec[i].appList[j] && currExec[i].allSign == '0') {
                    for (var k = 0; k < currExec[i].appList.length; k++) {

                        var grApp = new GlideRecord('sysapproval_approver');
                        grApp.get('sys_id', currExec[i].appList[k]);

                        if (grApp.state == 'requested') {
                            grApp.state = 'not_required';
                            grApp.update();
                        }
                    }
                    currExec[i].appList = '';
                    grItem.x_sap_intidn_sailpoint_mla_current_level = global.JSON.stringify(currExec);
                    grItem.update();
                } else if (current.sys_id == currExec[i].appList[j] && currExec[i].allSign == '1') {
                    currExec[i].appList.splice(j, 1);
                    grItem.x_sap_intidn_sailpoint_mla_current_level = global.JSON.stringify(currExec);
                    grItem.update();

                }
            }
        }
    }

    //validate approval
    var count = 0;
    grItem.get('sys_id', current.document_id);

    var currExec = global.JSON.parse(grItem.x_sap_intidn_sailpoint_mla_current_level);
    for (var i = 0; i < currExec.length; i++) {
        count += currExec[i].appList.length;
    }
  

    if (count == 0) {
        grItem.x_sap_intidn_sailpoint_mla_current_level = 'approved';
        grItem.update();
    }


})(current, previous);

 

 

Spoiler
 

 

2 . SP_SPNT_SNOW_INT_MLA_Approval_Manager_IW

 

 

(function executeRule(current, previous /*null when async*/ ) {
    var currExex = '';
    var grItem = new GlideRecord('sc_req_item');
    if (grItem.get('sys_id', current.document_id)) {

        //add checks for Idn workflow skip

        //REJECT	
        if (current.state == 'rejected') {

            var grPendingApps = new GlideRecord('sysapproval_approver');
            grPendingApps.addQuery('document_id', current.document_id);
            grPendingApps.query();
            while (grPendingApps.next()) {

                if (grPendingApps.state == 'requested') {
                    grPendingApps.state = 'not_required';
                    grPendingApps.update();
                }
            }

            grItem.x_sap_intidn_sailpoint_mla_current_level = 'rejected';
            grItem.update();
        } else if (current.state == 'approved') {

            var grPendingApps = new GlideRecord('sysapproval_approver');
            grPendingApps.addQuery('document_id', current.document_id);
            grPendingApps.query();
            while (grPendingApps.next()) {

                if (grPendingApps.state == 'requested') {
                    grPendingApps.state = 'not_required';
                    grPendingApps.update();
                }
            }
            grItem.x_sap_intidn_sailpoint_mla_current_level = 'approved';
            grItem.update();
        }
    }

})(current, previous);

 

 

 

3. SP_SPNT_SN_INT_CreateWorkNoteOnRITM

 

 

(function executeRule(current, previous /*null when async*/) {
	
	var workNoteMsg ='';
	if (current.getValue('state') == "not_required"){
		workNoteMsg = "Approval request by " + current.getDisplayValue('approver') + " is " + current.getDisplayValue('state') + ".";
	} else {
		workNoteMsg = current.getDisplayValue('approver') + " has " + current.getDisplayValue('state') + " the request.";
	}
	
	var grScReqItem = new GlideRecord('sc_req_item');
	if (grScReqItem.get(current.document_id)){
		grScReqItem.work_notes = workNoteMsg;
		grScReqItem.update();
	}
	
})(current, previous);

 

 

 

4.SP_SPNT_SN_INT_SyncApprovalId

 

 

(function executeRule(current, previous /*null when async*/ ) {

    var reqItem = new GlideRecord('sc_req_item');
    reqItem.addQuery('sys_id', current.document_id);
    reqItem.query();
    while (reqItem.next()) {

        var arr = [];
        var action = '';
        if (reqItem.variables.u_access_action == 'Add')
            action = 'GRANT_ACCESS';
        else
            action = 'REVOKE_ACCESS';

        var approvalsService = new x_sap_intidn.SP_SPNT_SNOW_INT_ApprovalsREST();
        var authScript = new x_sap_intidn.SP_SPNT_SNOW_INT_Auth();
        approvalsService.setAuthScript(authScript);
        var accessToken = new x_sap_intidn.SP_SPNT_SNOW_INT_Auth().getServiceAccountAccessToken();
        arr = approvalsService.getPendingApprovalsForRequestedObject(accessToken, reqItem.variables.u_identity_external_id, reqItem.variables.u_access_id, action);

        for (var i = 0; i < arr.length; i++) {
            var owner = approvalsService.getOwnerIdentity(arr[i].owner.id);
            var grUser = new GlideRecord('sys_user');
            if (grUser.get(gs.getProperty('x_sap_intidn.x_sp_spnt_snow_int.servicenow_account_attribute'), approvalsService._lookupV2object(owner, gs.getProperty('x_sap_intidn.x_sp_spnt_snow_int.spnt_identity_attribute')))) {
                 if (current.getValue('approver') == grUser.getValue('sys_id')) {
                    current.state_binding = arr[i].id;
                    current.update();
                }
            }
        }
    }

})(current, previous);

 

 

 

 

 

Which one should i check 

 

Please help me how to sort it out , with detailed steps .

 

@BharathChintala 

@Ankur Bawiskar 

@Sagar Pagar 

@SatyakiBose 

Thanks in Advance

 

 

11 REPLIES 11

@nameisnani 

it seems issue with that BR which they have shared in screenshot

try to add gs.info() and debug

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

@nameisnani 

I believe Ankur is correct, we are seeing the same issue with the SailPoint Plugin and have referred the error to SailPoint. It is a sloppy condition that assumes you are not using approvals for other standard ServiceNow applications such as Knowledge Management or Change Management where the approval record will not have an associated Catalog Item. How this got 'store certified' by ServiceNow I don't understand.

SatyakiBose
Mega Sage

Hello @nameisnani 

You actually have the answer on the error itself.

There are 3 business rule, and 2 workflows mentioned.

I woudl definetely start with deactivating them and then see if the issue replicates.

You should start with the BR 

1. SP_SPNT_SNOW_INT_MLA_Approval_Manager
2. SP_SPNT_SNOW_INT_MLA_Approval_Manager_IW
3. SP_SPNT_SN_INT_CreateWorkNoteOnRITM

 So the issue that seems to be here is that:

  1. Your script might be exactly the same on both the instances, but the field that the filter condition is using might be different or missing.
  2. I mean, for the instance where this is working might have a particular field which is present in the table.
  3. The instance where this not working, the field used in the filter condition might not be present in the instance.

Can you check the if all the field are present in both the instances?

@SatyakiBose  

 

could you please provide what was exact solution for that , we are unable to find out . 

I have made BR's deactivated as per your instructions then there was no issue found out.

 

When again we made it as active again same issue started , 

 

which conditon i have to check Please tell . 

Hello @nameisnani 

As I mentioned above, you need to check if the fields that are mentioned in the filter condition for the business rules are present in both the instances.

You need to go into the dictionary in both the instances, and compare that both the tables on both the instances have the same fields.

You need to check the fields mentioned in the filter conditions for all the business rules I mentioned above.

I will not be having access to your system, so you have to search it yourself.

You can check the documentation here - Data dictionary tables