- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 07:07 AM
Hi All,
I have an Widget(Request) from where I am calling another widget (RITM Variables).
In RITM Widget server side code is written as:
server side code:
(function(){
var gr = $sp.getRecord();
data.canRead = gr.canRead();
if (!data.canRead)
return;
data.tableLabel = gr.getLabel();
data.variables = $sp.getVariablesArray();
data.table = gr.getTableName();
data.sys_id = gr.getUniqueValue();
})()
Client Controller
function ($scope, spUtil) {
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
})
}
Request Widget Server side code where I am passing values
if(input.getDetailsWidget && input.table && input.sys_id){
data.details_widget = $sp.getWidget('widget-details', { table: input.table , sys_id : input.sys_id} );
return;
}
I am passing values (table and sys_id)trough input object from Request widget.
Here my issue is does $sp.getRecord() and $sp.getVariablesArray() will work when we are calling a widget from antoher widget as they take/consider current instance.Does they accept the value coming from input variable from calling widget(i.e table and sys_id).
I am getting following error:
Can any one guide/help me on this.
Developer Communitynathanfirthctomasi
Thanks,
Nithin.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 01:19 PM
When a widget is called using spUtil then the parameters passed are accessed using "input"
When a widget is called using $sp then the parameters passed are accessed using "options"
You can modify the code in the server side so it creates gr variable correctly - like so
var gr;
if(input && input.table && input.sys_id){
gr = new GlideRecord(input.table);
gr.get(input.sys_id);
}
else if(options.table && options.sys_id){
gr = new GlideRecord(options.table);
gr.get(options.sys_id);
}
else{
gr = $sp.getRecord();
}
if(!gr || gr == null){
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2017 01:16 AM
Hi Nithin,
Go for Try - catch to catch run time exceptions :
try {
// Your script for example:
- var gr;
- if(input && input.table && input.sys_id){
- gr = new GlideRecord(input.table);
- gr.get(input.sys_id);
- }
- else if(options.table && options.sys_id){
- gr = new GlideRecord(options.table);
- gr.get(options.sys_id);
- }
- else{
- gr = $sp.getRecord();
- }
- if(!gr || gr == null){
- return;
- }
}catch(error) {
// print error using "error"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 01:58 PM
The API was either designed by two different persons or by a single malicious person. In any case, not a good showcase of their work.