- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 11:20 PM
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)
(2)
Server Script:
(1)
var geFlg = new sn_hr_le.GetOBRecord().flugOn();
(2)
var geFlg2 = new sn_hr_le.GetOBRecord().updateVariables();
Thanks in advance,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 01:19 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 12:08 AM
Hi,
If you don't want to update then don't update but return true from script include and check in widget server script and based on that you can do your operation.
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 12:22 AM
Hi,
Exactly what I want to do!
How should I write if I want to update the widget side?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 12:09 AM
Hi,
call it like this; pass the glide record object
var geFlg = new sn_hr_le.GetOBRecord().flugOn(sysApprovalRecord);
update script include code as below:
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();
if(geFlg){
data.needDate = true;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 12:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 01:19 AM
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