Got: The undefined value has no properties. executing sn_cmdb.IdentificationEngineScriptableApi.createOrUpdateCI

Nicol_
Giga Contributor

Hi,
I've got this error:
org.mozilla.javascript.EcmaError: The undefined value has no properties.
Caused by error in <refname> at line 1

when executing:
sn_cmdb.IdentificationEngineScriptableApi.createOrUpdateCI

the code is:

function injectScopedAssetsIntoGlobalUsingReconciliation() {
	var injectFunction = function(grElement){
		gs.info('injectFunction ');
		var payload = {
			'items': [{
               'className': 'cmdb_ci_computer',
               'value': {
                       'name': 'Win Server 100',
                       'ip_address': '10.20.30.40',
                       'mac_address': 'ABCD1234'
               }
			}]
		};
		var input = JSON.stringify(payload);
		
		var output = sn_cmdb.IdentificationEngineScriptableApi.createOrUpdateCI(
			'ServiceNow', 
			input);
		
		gs.info('output ' + output);
	};
	
	injectFunction();
}

I'm trying to use reconciliation to add a row to the computer table.
I followed the documentation here.

The example here use SNC.IdentificationEngineScriptableApi.createOrUpdateCI but using SNC object I've got:
org.mozilla.javascript.EcmaError: "SNC" is not defined.
Caused by error in <refname> at line 1


I have the Configuration Management For Scoped Apps (CMDB) plugin active.

I'm running this script form my scoped app.

Any idea why?

Thank you!

2 REPLIES 2

Nicol_
Giga Contributor

Just an update, running this code as global works:

 

gs.info('injectFunction ');
		var payload = {
			'items': [{
               'className': 'cmdb_ci_computer',
               'value': {
                       'name': 'Win Server 100',
                       'ip_address': '10.20.30.40',
                       'mac_address': 'ABCD1234'
               }
			}]
		};
		var input = JSON.stringify(payload);
		
		var output = sn_cmdb.IdentificationEngineScriptableApi.createOrUpdateCI(
			'ServiceNow', 
			input);
		
		gs.info('output ' + output);

 

with SNC instead of sn_cmdb.
Running background script in the scoped app with sn_cmdb give the same error...

Nicol_
Giga Contributor

The problem was:

IdentificationEngineScriptableApi instead of IdentificationEngine, the first is for global scripts the second for scoped