In the previous post, I explained how to display informational or error messages using script. In the case of warning messages, these are handled in another way, because there is interaction with the user and depending on the user’s choice, a certain business logic is executed.
The message must have YES and NO response buttons (it could also have a CANCEL button).
def yesAction():
# Business logic for YES option
def noAction():
# Business logic for NO option
def cancelAction():
# Business logic for CANCEL option
def showMessage():
# Show the warning message
service.yncerror("msggroup", "msgkey")
cases = {
service.YNC_NULL : showMessage,
service.YNC_YES : yesAction,
service.YNC_NO : noAction,
service.YNC_CANCEL : cancelAction
}
if interactive:
# Get user's choice
choice = service.yncuserinput()
# Process user's choice using a python dictionary
cases[choice]()
If you found my post interesting or useful and just want to say thanks, you can always buy me a coffee.



