- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 02-10-2022 04:30 AM
Hi Guys,
I have build a custom application using studio. It fetches weather details from 3rd party REST API and renders it on Dashboard.
This is a practical application of Remote Tables in ServiceNow.
You can find the Custom App at ServiceNow Share here and follow the instructions to install.
Feel free to contribute on GitHub repo
https://github.com/sheikhafsarzap/CityWeather.git
Key Highlights
- REST Integration using outbound REST Message and custom Action.
- Remote Tables use case
- Service Portal Widget Development.
- Dashboard UI pages.
Implementation Steps
1. Sign up at RapidAPI to fetch weather details by city.
https://rapidapi.com/weatherapi/api/weatherapi-com/
2. Test 3rd party API to fetch city name by IP
3. Create Outbound REST message to fetch city name by IP.
Note:
- Custom app is designed to execute this REST message if logged in user profile has city as empty.
4. Create a custom Action To fetch weather details for the city.
Note:
- If the REST call returns an invalid city name. A default city weather is fetched via this action.
- Modify action header with necessary API key.
- Create a “Connection and Credential Alias”
5. Create a Remote Table to temporarily store weather details.
Create required columns based on widget design and action output.
6. Define Remote Table definition to execute the custom action.
Fetched weather details are populated on a defined Remote Table.
7. Add widget to dashboard
- Create a service portal widget >> “Current Weather”
- Load widget UI page >> “current_weather” in a new UI page >> “WeatherData” (render service portal ui page in iframe via URL).
- Create a new dashboard widget by navigating to "System UI >> Widget" (Render Type as "JavaScript").
- Return UI page >> “WeatherData” via script.
- Create a dashboard >> “ My city weather”
- Add widget to dashboard.
Disclaimer:
If you face issues when rendering UI page on Dashboard widget (in case of Custom Scope), follow my comment on below community thread.
References
-
https://www.snow-adventures.com/blog/using-remote-tables-in-service-now/
-
http://mkallasoja.net/blog/create-a-weather-widget-service-now/
Please mark this article helpful if applicable.
Feedbacks to improve the content are most welcome.
Happy Learning!
Thank You
Afsar Sheikh
- 2,558 Views