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"])}
Solved! Go to Solution.
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)
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)
@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)
When I change the opening_hours_strings in the last line to opening_hours, it presents the right outcome but duplicated.
Thanks again
Toby
All sorted, got it to work
Thanks for the help