$sp.getRecord does not work in scoped application . servicenow bug ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:57 AM
Hi everyone.
I'm sucked in below problem.
If i put this code into a scoped portal widget's servier side script , the script will stop at line2 ($sp.gerRecord) without any errors or warnnings...
But if i put it into a global widget , everything goes well ...I don't know why...
gs.info('yyyyyyy ' + data.table + data.sys_id);
var rec = $sp.getRecord('sc_req_item', 'ccbaa13c47ea8e10ea269dbe316d43f8');
gs.info("xxxxx")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:16 AM
Hi @newhand
"getRecord", not supported in scoped app.
please query the sc_req_item table with sysId and get the catalog record.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:24 AM
Hi @newhand ,
In scoped application $sp.getRecord will not work you can use below script
var gr = new GlideRecord('sc_req_item');
if(gr.get('ccbaa13c47ea8e10ea269dbe316d43f8')){
gs.info("xxxxx");
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 04:14 AM
Hi @newhand
Refer to the below link.
https://serviceportal.io/docs/documentation/widget_server_script_apis.md
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 06:32 PM
@Community Alums @Rajesh Chopade1
Finally , I caught the error with try-catch。
Yes,as the error message says, getRecord is not supported in scoped application。
But according to the official document below,it should be supported in the scoped application。。。
And I also found an OOTB widget in the scoped application using getRecord (I'm not sure if it works...)。
I