cancel
Showing results for 
Search instead for 
Did you mean: 

Widget to display time

R1
7 - Data Storage
7 - Data Storage

Hi,

We have a requirement where we have to display the local timezone of the country that is being selected from the dashboard filter. The dashboard filter on country has values like Italy, France, Netherlands, UK, US etc. When the user selects "Italy" in the filter, i want the widget to display the value of Italy's local time, irrespective of the timezone of the user. The same widget should display France's local time when the user selects "France" from the filter. Do we have an out of box/ built-in widget to display time (like a clock widget).

6 REPLIES 6

Harry
9 - Travel Pro
9 - Travel Pro

Hello @R1 ,

One solution is to add a Text widget to dashboard and add below dashboard script. In the script, update the variable 'filterName' with name of Country filter, 'textWidgetID' with ID of Text widget and 'countryTimeZoneMapping' with area-time zone name mapping


dashboard.on('filterschanged', function(se, ev){
	displayTime(se)
})

dashboard.on('widgetready', function(se, ev){
	displayTime(se)
})

function displayTime(se){
	let filterName = 'Country' //update the name of country filter
	let textWidgetID = '6380c6426bc7f50039bf366b' //update widget-id of text widget
	
	
	let selectedCountry = ''
	
	//update area-timezone mapping
	let countryTimeZoneMapping = {
		'Brazil':'America/Sao_Paul',
		'France':'Europe/Paris',
		'Canada':'America/New_York',
		'India':'Asia/Calcutta'
	
	}
	
	let filterObject = se.filters.$$items.find(el=>el.jaql.title == filterName)
	
	if(filterObject && filterObject.jaql.filter && filterObject.jaql.filter.members)
		selectedCountry = filterObject.jaql.filter.members[0]
	
	let dateString = new Date().toLocaleString('en-US', { timeZone: countryTimeZoneMapping[selectedCountry]});
	$(`widget[widgetid="${textWidgetID}"] richtexteditor .wd`).text(dateString)

}

 

Harry_0-1669387352448.png

Harry_1-1669387379884.png

 

Please let me know if have any questions

Always here to help,
Harry from QBeeQ

QBeeQ - Gold Implementation and Development Partner
www.qbeeq.pl

 

 

R1
7 - Data Storage
7 - Data Storage

Hi Harry,

Thank you so much. That helps. Could you kindly let me know how do i find the widget ID of the text widget in question?

Regards,

R

R1
7 - Data Storage
7 - Data Storage

Hi Harry,

Thank you so much. That helps. Could you kindly let me know how do i find the widget ID of the text widget in question? I tried finding out the widget ID of the text widget from the Console by giving "prism.activeDashboard.widgets.toArray()" and got the ID. But, the time doesn't get displayed while selecting the filter. Attaching the screenshot of the dashboard too.

Screenshot 2022-11-28 at 2.05.03 PM.png

Screenshot 2022-11-28 at 2.01.19 PM.png

Screenshot 2022-11-28 at 1.55.52 PM.png

 

Harry
9 - Travel Pro
9 - Travel Pro

One simple method to fins widget id is, open Script Editor window of the Text Widget and copy widget id from URL.

Harry_0-1669629878629.png

In below screenshot, widget ID is highlighted in yellow color

Harry_2-1669630147240.png

 

Please let me know if have any questions

Always here to help,
Harry from QBeeQ

QBeeQ - Gold Implementation and Development Partner
www.qbeeq.pl

 

R1
7 - Data Storage
7 - Data Storage

Thank you Harry. I was able to find the ID of the text widget. However, date doesn't get displayed dynamically according to the filter value. My dashboard filter name is "marketname". Attaching the dashboard script and dashboard for reference. Is there something that i'm missing here?

Screenshot 2022-11-28 at 3.55.56 PM.png

Screenshot 2022-11-28 at 3.56.55 PM.png

R1
7 - Data Storage
7 - Data Storage

Hi, Any help here is highly appreciated. I was able to find the ID of the text widget. However, date doesn't get displayed dynamically according to the filter value. My dashboard filter name is "marketname". This task is of high priority for us to deliver and could we please get on a call to go over this? I see this solution working for you but not for us and so wanted to understand if we're missing something. Attaching the dashboard script and dashboard for reference.

Screenshot 2022-11-29 at 12.04.00 PM.png

Screenshot 2022-11-29 at 12.04.39 PM.png