Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to call script include function from script-background

cc11
Tera Contributor

I have a simple script include function that I want to test from script background. I tried the scripts below, but it doesnt seem to be doing anything.

Script background (to call function - "eventMessage"): 

var update = new UpdateTask();
UpdateTask.eventMessage('sc_task','7','request_item.number','RITM0000001');

 

Script Include (has the function"eventMessage" which updates sc_task table's State field):

var UpdateTask = Class.create();
UpdateTask.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
eventMessage:function(eventTable,eventState,eventField1Name,eventField1Value){
		var rec = new GlideRecord(eventTable); //name of the Task table to be updated
		rec.addQuery(eventField1Name,eventField1Value);  
		rec.query();
		while(rec.next()) {
			if(eventState){
				rec.state = eventState; //Status value 7: Close-Skipped
				rec.update();
			}
		}
		
		
	},
	type: 'UpdateTask'
});
1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage
Try this: var update = new UpdateTask(); update.eventMessage('sc_task','7','request_item.number','RITM0000001');

View solution in original post

2 REPLIES 2

Jon Barnes
Kilo Sage
Try this: var update = new UpdateTask(); update.eventMessage('sc_task','7','request_item.number','RITM0000001');

cc11
Tera Contributor

Thank you Jon!

I spot the mistake I was making 🙂

 

Thank you again,

Yogesh