choose from list
возвращает false
, если пользователь нажимает Cancel
или список элементов, даже если with multiple selections
не включено.
Вы должны сгладить список до выражения if - else
set currentSupport to "" -- initialize the variable
set supportList to choose from list {"A", "B"} with prompt "Source:" default items {"A"}
if supportList is false then return
set currentSupport to item 1 of supportList
set currentPR to "" -- initialize the variable
if currentSupport is "A" then
set misrouteList to choose from list {"1", "2", "3", "4"} with title "Prepared Responses" with prompt "Reason:"
if misrouteList is false then return
set currentPR to item 1 of misrouteList
else if currentSupport is "B" then
set misrouteList to choose from list {"5", "6", "7", "8", "9", "10"} with title "Prepared Responses" with prompt "Reason:"
if misrouteList is false then return
set currentPR to item 1 of misrouteList
end if
set supportChoice to currentSupport
set prChoice to currentPR
или без избыточного кода
set supportList to choose from list {"A", "B"} with prompt "Source:" default items {"A"}
if supportList is false then return
set currentSupport to item 1 of supportList
if currentSupport is "A" then
set responseList to {"1", "2", "3", "4"}
else -- there is only A or B
set responseList to {"5", "6", "7", "8", "9", "10"}
end if
set misrouteList to choose from list responseList with title "Prepared Responses" with prompt "Reason:"
if misrouteList is false then return
set currentPR to item 1 of misrouteList
set supportChoice to currentSupport
set prChoice to currentPR
или оставьте выбор в виде списка и проверьте {"A"}
set supportList to choose from list {"A", "B"} with prompt "Source:" default items {"A"}
if supportList is false then return
if supportList is {"A"} then
set responseList to {"1", "2", "3", "4"}
else
set responseList to {"5", "6", "7", "8", "9", "10"}
end if
set misrouteList to choose from list responseList with title "Prepared Responses" with prompt "Reason:"
if misrouteList is false then return
set supportChoice to item 1 of supportList
set prChoice to item 1 of misrouteList