Disable default attachment folder

One of the fist lessons I have learned through all these years as Maximo consultant is that every time there is a default value for a field the user will not change it. A very common example of this is the Folder field of the Add Attachment dialog.

The value of this field will always default to the first folder available in alphabetical order. If we want to force the user to select the most appropriate folder for the attachment, then we have to remove that default value.
The attribute we want to change is DOCLINKS.DOCTYPE. Unfortunately, setting a default value for this field in Database Configuration will not work (believe me I have tried) so we have use a more powerful feature to control the behavior of this attribute. The solution I have found is to use a very simple automation script. Here it is.

Open the Automation Scrips application and create a new record with the following data:

  • Type: Script with Attribute Launch Point
  • Launch Point: DOCTYPEDEFAULT
  • Description: Reset default Attachment Folder for application WOTRACK
  • Object DOCLINKS
  • Attribute: DOCTYPE
  • Event: Run Action
  • Script: DOCTYPEDEFAULT
  • Script Language: python
  • Source: paste code below
#-------------------------------------------------------------------------------------------------------------
# Script: DOCTYPEDEFAULT
# Launch Point: DOCLINKS.DOCTYPE - Run Action
# Reset default Attachment Folder for application WOTRACK
#-------------------------------------------------------------------------------------------------------------
from psdi.mbo import MboConstants

if mbo.getOwner() is not None:
  # reset the default value only for a specific set of applications
  if mbo.getOwner().getThisMboSet().getApp() in ("WOTRACK", "ASSET"):
    if mbo.getMboValue("DOCTYPE").getPreviousValue().asString()=="":
      # set an invalid value so the user is forced to set a correct value
      mbo.setValue("DOCTYPE", "-", MboConstants.NOVALIDATION)

The script is quite simple.

  1. It first checks if the owner application is in a specific set. This is because we may need to override the default behavior only for a specific set of applications. In the example it work only for Assets and Work Order Tracking applications.
  2. Verifies that the previous value of the DOCTYPE field is not already set. I have used this trick to detect if the attribute was just initialized or the user already set the value.
  3. Sets an invalid value ‘-‘ so the user is forced to set an appropriate folder.
Disable default attachment folder
Share this post...

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top