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

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

it seems some BR has issue with condition

you are dot walking document_id field to cat_item

if the BR is for RITM then you can check that in script which catalog item it is

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

@Ankur Bawiskar 

 

We have not changed any script these are coming from the Plugins , Last week we did plugin upgrade from that day onwards we are getting this error . 

 

What steps i need to take @Ankur Bawiskar currently it is happening in Dev only , how to sort it out @Ankur Bawiskar please provide steps . 

@nameisnani 

can you compare then dev and test

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

@Ankur Bawiskar 

 

These BRs are not there in Stage .

 

SunilKumarPadh_0-1678078504442.png

we have not done upgrade in Stage we have done in Dev only . 

 

I think we need to change in the script level could u please tell where i need to change so that issue will stop.