Pull a record from Remote table and add field values to a custom widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 12:09 AM
Hi,
Idea is to leverage on Remote Tables.
I am trying to fetch weather related data from an opensource API and create a record in remote table.
I am able to populate the remote table with weather details based on session user's location.
I want to pull this details into custom widget.
The server script in custom widget is not able to fetch glide record from remote table.
Same GlideRecord script is able to fetch data from other tables but fails for Remote Tables.
Any suggestions?
Regards,
Afsar Sheikh
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2022 07:21 AM
Hi Afsar,
I tried to reproduce this issue. I created one remote table in scoped application and tried to access it using GlideRecord query.
It worked as expected.
I have created it with below permissions:
Also created one definition record. If I deactivate definition then it throws an error.
If I activate definition and comment the script which was adding dummy records then it returns zero record.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2022 07:34 AM
Hi,
Please check below examples, how external source is used to get data and use v_table.addRow() to add records.
These records will be available when you make GlideRecord query.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2022 08:36 AM
Hi,
Please follow the steps below to achieve your requirement:
This is working for me and tested in my PDI instance.
1) I have created a new Remote Table in a Custom Scope as needed as shown below where I have two field Name and Short Description created as shown below:
2) Now once you have created the Remote table, next step is to create a Definition for the Remote Table. Navigate to the module "Definition as shown below:
3) Click on New button and say add your script which you want to insert data into this Remote Table. I have created a demo sample script so that a record gets inserted into this Remote Table as shown below:
Script:
(function executeQuery(v_table, v_query) {
var rec = {};
rec.sys_id = '23456';
rec.u_name = 'System Admin';
rec.u_short_description = 'this si for community helping users';
v_table.addRow(rec);
})(v_table, v_query);
Output 1:
Data inserted into my Remote Table as shown below:
Now in order to show this data into Service Portal, you do not need to create a Custom widget here and would suggest to make use of OOB capability which allows you to do the same job:
1) Navigate to Page module under Service portal Application menu as shown below:
Now open the page where you need to add the widget to display the data, I have created a new page in my custom scope as shown below:
Click on Open in Designer as shown below after opening your Page record:
Now add this widget in the container where you need to add "Data Table from Instance Definition"
Now once this widget is added, Navigate to widget module and open this widget as shown below: "Data Table from Instance Definition"
After opening the widget record scroll down to "Instance" related list as shown below:
Now open the record where title is blank and select your table Name i.e. Remote Table Name with fields as shown below:
Once this is done, Navigate to your portal page and result are as you need:
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2022 02:14 AM
Hi
I really appreciate your help.
I was able to add row to remote table and fetch in a custom widget in service portal.
Soon I'll be posting an article with the details about the task.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2022 03:01 AM
Hi Afsar,
Glad your query is resolved. Can you mark my answer as correct and close this thread for other.
Regards,
Shloke
Regards,
Shloke