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 Language: python
  • Source: paste code below
# 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

2 thoughts on “Disable default attachment folder

  1. This script was similar to what I was looking for, was able to modify it and use it… only to find it caused an issue with making an attachment on an email generated from a workorder (with a comm template). I’m not sure what app or mbo is being used in this scenario, but even with this script in its unmodified form i’m getting an error…

Leave a Reply

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

Scroll to top