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

Alex Macdonel
Tera Expert

I've done additional testing and it seems that business rules (from same scoped app, not sure about others) with an 'on change' condition are breaking when I process the inbound action.

Why? Because every time I process the inbound action that makes a change to my task record I see errors like this: 

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

I was trying to fire a notification with an 'on change' condition but this was breaking too. I worked around this by queuing an event from my inbound action... 


Opened a support ticket and will see what happens with it.

Do you have any update on this ?

lexifouts
Tera Expert

For anyone wondering about the resolution on this error, I came across this issue today in a Tokyo instance with a Fix Script I was running. I was trying to insert a record into a scoped table (my fix script was in the same scope, as were all the business rules). The script would insert the record but none of the business rules executed and I received the errors mentioned in this post for each one.


Turns out the issue is not related to scope or access, but because my fix script had a variable named "current" (tsk tsk) and it was causing a conflict. To fix this you need to ensure you have no variables named "current" in your script, or if you really need to - encapsulate it in a function.

 

Hope this helps someone!