ATF FAILURE: Unable to insert record into table 'cmdb_ci_service'.

Community Alums
Not applicable

Hi,

I have written a test case and it is failing on the error 

 

FAILURE: Unable to insert record into table 'cmdb_ci_service'. Details:
Operation against file 'cmdb_ci_service' was aborted by Business Rule 'Check Uniqueness for SN App Service ID^55cb4dbc1bd039903e27fd9f034bcb66'. Business Rule Stack:Check Uniqueness for SN App Service ID

 

test case 1.PNGtest case 2.PNGtest case 3.PNG

 

Error 1.PNGError 2.PNG

Business Rule

 

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

	var curNum = current.number + '';
    if (current.operation() == "update" && previous != null && curNum == (previous.number + '')) {
        // For Update, if number has not changed no need to verify uniqueness
        return;
    }
	
	if (JSUtil.nil(curNum)) {
		gs.addErrorMessage(gs.getMessage("Invalid {0}. The number field cannot be empty.", [current.operation()]));
        current.setAbortAction(true);
		return;
	}
	
    // When Inserting new record or when value of number has changed, verify uniqueness
    var gr = new GlideRecord("cmdb_ci_service");
    gr.addQuery("number", curNum);
    gr.query();
    if (gr.getRowCount() > 0) {
        gs.addErrorMessage(gs.getMessage("Invalid {0}. Service with SN App Service ID: {1} already exists.", [current.operation(), curNum]));
        current.setAbortAction(true);
    }

})(current, previous);

 I can easily make the Test Step false and make it run, But I want to know what is going on. Kindly help.

Regards

Suman P.

 

7 REPLIES 7

Michael Fry1
Kilo Patron

I'm thinking you ran this ATF and it failed but instead of rolling back all the changes, it left a business service named Sample ATF Business Service. If it exists, delete it and then try your ATF again.

Community Alums
Not applicable

Hi @Michael Fry1 ,

Thank you so much. I tried it, but there is no entry with Sample ATF Service. 

 

Business service.PNG

 

test case 3.PNG

Regards

Suman P.

There is a sysID in the error. What record comes up when you look for that sysID? Try adding a 1 or 2 to the end of the name.

Community Alums
Not applicable

Hi @Michael Fry1 ,

I tried looking for sysid with 55 as it contained 55 in the error. I got some results, but there is no 'Check Uniqueness'.

sysid.PNG

Regards

Suman P.