Automation script to implement Yes/No confirmation messages in Maximo

Below script can be used to implement Yes/No prompt message taken from IBM documentation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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 ():
	params=[str(priority)]
	service.log("Throw ERROR")
	# Use the service utility's yncerror() method to push the choice message
	# The below key and group combination should be added in Database configuration -> Messages
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 cases[x]()

Above code calls the yes() or no() method using python's dictionary. If it looks slightly confusing you can find a somewhat similar StackOverflow answer here.  

Comments

Popular posts from this blog

BMXAA6713E - The record could not be retrieved from the database. Error

Rebuilding Maximo Text Indexes due to Query performance issues

List of things checked by Maximo Integrity checker