Example: Configuring choice messages

A company requires that whenever the highest priority level is assigned to an asset, then an email is sent to the asset custodian. An automation script is created to send this email. The automation script uses a choice message to confirm that the email should be sent.

About this task

The example launch point and automation script that implements a choice message, and its processing uses the Jython programming language.


  1. In the Database Configuration application, select the Messages action and create a new message with the following values:
    Fields Values
    Message Group asset
    Message Key assetpriorityemail
    Display Method MSGBOX
    Message ID Prefix BMXZZ
    Message ID Suffix W
    Display ID 1
    Value Asset custodian can be notified through email when priority {0} is set. Send email?
    Buttons section Check Yes and No buttons.
  2. In the Automation Scripts application, create a script with an attribute launch point to run the Attribute Launch Point wizard.
  3. In step 1 of the wizard, specify the launch point name, and select the ASSET object and the PRIORITY attribute.
  4. In the Events section, choose the Run Action radio button.
  5. In step 2 of the wizard, specify the script name and set the log level to debug.
  6. In step 3 of the wizard, paste in the following source code and then click Create:
    # Business logic implementation if user selects Yes choice (clicks Yes button)
    def yes ():
    	service.log("Sending Email")
    # Business logic implementation if user selects No choice (clicks No button)
    def no ():
    	service.log("Not Sending Email")
    # Business logic to present the choice message initially
    def dflt ():
    	service.log("Throw ERROR")
    	# Use the service utility's yncerror() method to push the choice message
    	service.yncerror("asset", "assetpriorityemail",params);
    service.log (’$$SAM$ - entering ASSETPRIORITYVAL’)
    # Declare the user input choices and the corresponding functions implemented in this script
    cases = {service.YNC_NULL:dflt, service.YNC_YES:yes, service.YNC_NO:no}
    # Make sure the choice message is presented only 
    #if the field validation was triggered from user interface
    if interactive:
    	if priority < 2:
    		service.log ("About to do something")
    		# Use the service utility's yncuserinput() method to trigger the entire interaction
    		# User's response is stored in a local variable x
    		x = service.yncuserinput()
    		service.log("User input: "+str(x))
    		# Process the user input using Jython's case statement

What to do next

To test your script, in the Assets application, select a record and set the priority to 1. When a choice message appears, select a choice.