Select to view content in your preferred language

Arcade in Popups

764
3
Jump to solution
02-20-2022 10:22 PM
TobyStewart2
Emerging Contributor

I have a feature layer from Survey 123 Connect

It has 3 fields for business hours for each day of the week

Ie: Open or Closed & if open was selected in the survey the next two fields
Open time 

Closed time  became available.

I am trying to configure the popup to show 

"Business Hours" all together.

I have worked out the Arcade expression for one day but cannot work out how to add the other days.

Hope this makes sense and someone can help

Thanks

My expression:

if ($feature["sunday_open_close"] == "closed")
return "Sunday - Closed";
else {
return "Sunday" + (' - ') +
Concatenate($feature["sunday_open"],(' - '),$feature["sunday_close"])
}

// wednesdays times

if ($feature["wednesday_open_close"] == "closed")
return "Wednesday - Closed";
else {
return "Wednesday" + (' - ') +
Concatenate($feature["wednesday_open"],(' - '),$feature["wednesday_close"])}

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Alum

Something like this (untested)?

 

// define list of week day and opening hours
var opening_hours = [
  ["Sunday", $feature.sunday_open_close, $feature.sunday_open, $feature.sunday_close],
  ["Monday", "$feature.monday_open_close, $feature.monday_open, $feature.monday_close],
  // ...
]
// build string for each week day
var opening_hours_strings = []
for(var i in opening_hours) {
  var oh = opening_hours[i]
  var oh_string = oh[0] + " - Closed"
  if(oh[1] != "closed") {
    oh_string = Concatenate([oh[0], oh[2], oh[3]], " - ")
  }
  Push(opening_hours, oh_string)
}
// Concatenate the week days with line breaks
return Concatenate(opening_hours_strings, TextFormatting.NewLine)

 


Have a great day!
Johannes

View solution in original post

3 Replies
JohannesLindner
MVP Alum

Something like this (untested)?

 

// define list of week day and opening hours
var opening_hours = [
  ["Sunday", $feature.sunday_open_close, $feature.sunday_open, $feature.sunday_close],
  ["Monday", "$feature.monday_open_close, $feature.monday_open, $feature.monday_close],
  // ...
]
// build string for each week day
var opening_hours_strings = []
for(var i in opening_hours) {
  var oh = opening_hours[i]
  var oh_string = oh[0] + " - Closed"
  if(oh[1] != "closed") {
    oh_string = Concatenate([oh[0], oh[2], oh[3]], " - ")
  }
  Push(opening_hours, oh_string)
}
// Concatenate the week days with line breaks
return Concatenate(opening_hours_strings, TextFormatting.NewLine)

 


Have a great day!
Johannes
TobyStewart2
Emerging Contributor

@JohannesLindner  thanks for your reply

unfortunately it has only partially worked.

It has listed the days however it hasn't added the time next to the days.

This what I did:

// define list of week day and opening hours
var opening_hours = [
["Monday", $feature.monday_open_close, $feature.monday_open, $feature.monday_close],
["Tuesday", $feature.tuesday_open_close, $feature.tuesday_open, $feature.tuesday_close],
["Wednesday", $feature.wednesday_open_close, $feature.wednesday_open, $feature.wednesday_close],
["Thursday", $feature.thursday_open_close, $feature.thursday_open, $feature.thursday_close],
["Friday", $feature.friday_open_close, $feature.friday_open, $feature.friday_close],
["Saturday", $feature.saturday_open_close, $feature.saturday_open, $feature.saturday_close],
["Sunday", $feature.sunday_open_close, $feature.sunday_open, $feature.sunday_close],
]
// build string for each week day
var opening_hours_strings = ["Monday",'Tuesday','Wednesday','Thursday','Friday', 'Saturday', 'Sunday']
for(var i in opening_hours) {
var oh = opening_hours[i]
var oh_string = oh[0] + " - Closed"
if(oh[1] != "closed") {
oh_string = Concatenate([oh[0], oh[2], oh[3]], " - ")
}
Push(opening_hours, oh_string)
}

// Concatenate the week days with line breaks
return Concatenate(opening_hours_strings,TextFormatting.NewLine)

TobyStewart2_0-1645488482611.png

When I change the opening_hours_strings in the last line to opening_hours, it presents the right outcome but duplicated.

TobyStewart2_1-1645488580413.png

Thanks again

Toby

 

0 Kudos
TobyStewart2
Emerging Contributor

All sorted, got it to work 

Thanks for the help 

0 Kudos