Error when setting item in Script Include

CarlJSchmidt
Tera Expert

Hi there, 

 

when working with a scoped Script Include, I face the issue, that I cannot write into the document of the request.
My Script Include is defined similar to this:

 

 

var TestAjax = Class.create();
TestAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    initialize: function() {
    },
	testFunction: function() {
		var gr = new GlideRecord('sys_user');
		gr.query();

		while (gr.next()) {
			var item = this.newItem();     // <--- `item` is undefined

			item.setAttribute('sys_id', gr.getValue('sys_id'));
			item.setAttribute('name', gr.getValue('name'));
		}
	},
    type: 'TestAjax'
});

 

 

 

When testing this Script Include via a Fix Script, I receive the following error:

 

 

Evaluator: com.glide.script.RhinoEcmaError: The undefined value has no properties.
   script : Line(10) column(0)

 

 

Line 10 is the line where I first try to set an attribute for the item element, indicating that item is undefined.

 

Thanks to @Alikutty A who describes the implementation of this.newItem(), I also tried to explicitly redefine this method in the scoped Script Include. But unfortunately, this also did not solve the issue.

 

Is there anything to take special car of when writing Script Includes for scoped applications other than using global.AbstractAjaxProcessor instead of AbstractAjaxProcessor?

 

Any help is much appreciated! Thank you!

1 ACCEPTED SOLUTION

Hi @CarlJSchmidt 

Looking like the Client Callable checkbox is missing in your script include. Make sure your to enable it.

Screenshot 2024-03-22 at 10.58.32.png

 

Cheers,

Tai Vu

View solution in original post

6 REPLIES 6

Hi @CarlJSchmidt 

Looking like the Client Callable checkbox is missing in your script include. Make sure your to enable it.

Screenshot 2024-03-22 at 10.58.32.png

 

Cheers,

Tai Vu

Hey @Tai Vu,

 

thank you again for your support! Indeed, the checkbox was the reason for that issue 🙄
Really appreciate your help here!

 

Best wishes,

Carl