- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 07:12 AM - edited 03-15-2024 07:45 AM
I am trying to get hold of the record the widget is related to when the widget loads. I.e. no input will be available.
It is a scoped environment but I think $sp should work anyway (since GlideSPScriptable is available as a scoped API). $sp exist since (typeof $sp) prints 'object'.
Server Script:
(function() {
gs.error("$sp? " + typeof $sp);
gs.error("record? " + $sp.getRecord());
})();
Output:
$sp? object
record? null
Is there something I need to think about to get this working which I, apparently, cannot find in any docs?
Update: This is to be loaded when clicking to see my To Dos in the portal.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 02:25 AM
Hi @Niklas6,
According to the document, 'getRecord' returns the following:
If parameters are provided, returns the record identified by the provided table and Sys ID.
If no parameters are provided, returns the record identified by the current URL.
Returns null if the widget is embedded by another widget, or if the record for the provided parameters is not found.
With the 'hrm_todos_page' (I assume this is the page you are talking about), I don't see the table nor the sys_id of the selected task in the URL hence it's returning null. If you can elaborate on what you are trying to do, maybe we can assist you further.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 01:07 AM
Hi @Niklas6
Try getting the sysid from URL & get its gliderecord.
The $sp.getParameter() method retrieves the sys_id from the request querystring. You may require to use $sp.getParameter("sys_id") in this case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 11:31 PM - edited 03-17-2024 11:31 PM
No functions work. But I fixed it if you look at my other comments. Thanks'!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 02:25 AM
Hi @Niklas6,
According to the document, 'getRecord' returns the following:
If parameters are provided, returns the record identified by the provided table and Sys ID.
If no parameters are provided, returns the record identified by the current URL.
Returns null if the widget is embedded by another widget, or if the record for the provided parameters is not found.
With the 'hrm_todos_page' (I assume this is the page you are talking about), I don't see the table nor the sys_id of the selected task in the URL hence it's returning null. If you can elaborate on what you are trying to do, maybe we can assist you further.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 11:30 PM - edited 03-18-2024 01:45 AM
The third line of the spec you provided is the one related to this scenario. It is embedded and, hence, null is returned. I solve the problem at hand by accessing the options object which had been populated.