How to call script include from server script

Mi4
Tera Expert

Hello
please tell me.
I want to call a script include in the widget server script.

I can now call the script include, but the contents of the script include are not running.

(Script include can be executed by itself, so I guess I have a problem writing the script include and the calling part of the server script)

How should I write?

 

There are two points I want to call.
(1) If the conditions are met, turn the flag ON.

(2) If the conditions are met, update the record.

Script Include:
(1)
find_real_file.png
(2)
find_real_file.png

Server Script:
(1)

var geFlg = new sn_hr_le.GetOBRecord().flugOn();
(2)

var geFlg2 = new sn_hr_le.GetOBRecord().updateVariables();


Thanks in advance,

1 ACCEPTED SOLUTION

Hi,

The script include call will be like Ankur mentioined in previous comment.

var geFlg = new sn_hr_le.GetOBRecord().flugOn(sysApprovalRecord);

One thing I noticed in script include is that the script you have is a client callable one but your client callable check box in unchecked. The client callable checkbox should be unchecked if you are calling the script include from server side. So you need to update your script, Please try using the below script include.

var GetOBRecord = Class.create();
GetOBRecord.prototype = {
	initialize: function() {
	},
	flugOn: function(sysApprovalRecord){
		var cse = new GlideRecord('sn_hr_le_case');
		cse.addQuery('sys_id', sysApprovalRecord.document_id);
		cse.addQuery('hr_service', 'eb0e5456dbc41010e6b98a184896192d');
		cse.addQuery('le_progress', 'Approver Waiting');
		cse.setLimit(1);
		cse.query();
		return cse.hasNext();
	},
	type: 'GetOBRecord'
};

 

Now, coming to your query

I want to use or update a widget's record within a script include, is that not possible? - Yes you can update a record in a script include, but if you want to display something only on the widget and don't want to save it then you need to have a code in widget's client side script and angular/html.

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Alok

View solution in original post

10 REPLIES 10

Hi,

oh, I'm sorry,and Thanks for pointing out. I fixed it there.

Sorry, the script was incorrect. Please tell me again.

I want to return this "data" (only in the server script) to the server script as "true" in the script include.

Is this possible? The current script is d below.