Getting error: org.mozilla.javascript.EcmaError: The undefined value has no properties. on scoped app while processing inbound action

Alex Macdonel
Tera Expert

While working on a scoped app I created a third option besides approve and reject called amend for an approval email. I then created an inbound action that runs at the same time on the sysapproval_approver table that is looking for the keyword 'amend'.

The inbound action has the following script:

 

var r = current.sysapproval.sys_id.toString();
if (current.getTableName() == "sysapproval_approver") {
	if (current.source_table == 'x_nea_task') {
		if (validUser()) {
			if (email.subject.indexOf("amend") >= 0) {
				amend(r);
			}
		}
	}
}

function amend(id) {
	// code to remove the watermark from the reply
	var com = email.body_text;
	var ref = com.match(/Ref:.*[0-9]/);
	var index = com.indexOf(ref) + (ref.toString().length - 14);
	var extract = com.substring(0, index);
	//get the actual task
	var grTask = new GlideRecord('x_nea_task');
	grTask.get('sys_id', id);
	grTask.state = '2';
	grTask.comments = extract;
	//gs.info('grTask number: ' + grTask.number);
	grTask.update();
}

 

When I send an email with the word amend on the subject line I can see that the inbound action runs, my record changes its state to 2 (work in progress) but all associated business rules (mine and SN's) fail with the following error:

org.mozilla.javascript.EcmaError: The undefined value has no properties.

All my business rules are triggered on field changes (simple conditions built through the UI), and the errors are all similar; one of them is:

org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in <refname> at line 1 ==> 1: function trecord() {return !!(current.submitted_by_id.changes());}trecord();

The trecord() code is not mine, that is done automatically by SN.

It appears that SN is having issues figuring out which record was changed. Has anyone seen this or can give me ideas on how to troubleshoot this?

 

 

 

 

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Alex,

 

Is the inbound action created in the same scope? Also, can you share the screenshot of table "Application Access Setting" for x_nea_task?

 

Thanks,

Pradeep Sharma

here it is in its current state, I tried having allow configuration enabled on one of my tests but that didn't work:

find_real_file.png

 

I can confirm that all is under the same scope - it's my first scoped app. After looking at the logs, I think that what I thought were SN business rules is in fact my actual inbound action and it's complaining about the line that calls the amend function and the update() based on the numbers where the errors are reported:

org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in sysevent_in_email_action.05d38d5c4f755b4061fc5fde0310c7ee.script at line 10

and

org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in sysevent_in_email_action.05d38d5c4f755b4061fc5fde0310c7ee.script at line 37

Not only do the business rules don't work, a notification I have that is using a 'change to' condition is not being triggered either...

find_real_file.png

 

I don't care about the business rules, I know that nothing is changing when I receive the amend email, but I do care that this email isn't being fired when the inbound action executes.

If I make the change manually on the task itself, the mail is sent.

Thanks Alex for the update. I'm not exactly sure on what else might be the reason for it to fail. I will be doing an investigation at my end and let you know if I have any positive response for you.

 

Thanks,

Pradeep Sharma