August 10, 2012

How to set the default value of a field in Maximo

There are five ways to set the default value of a field in Maximo.

Database Configuration

The first way is to set the default value at the database level using Database Configuration.
All you have to do is the object and then the attribute for which the default is to be set. In the right hand side of the Details section there is a Default field. This is where you would enter your literal value for the default value.
Some system constants can be used:
  • &AUTOKEY& - This is used for attributes that are set to autonumber to default to the next autonumber value.
  • &SYSDATE& - This will default a field with the current system date/time
  • &USERNAME& - This will default a field to the current USERID value
  • &PERSONID& - This will default the current user's PERSONID value.
Note: These system defaults can be used only in Database Configuration.


Application Designer

The second way to set a field default in Maximo is by using a Default Object in Application Designer.
Launch Application Designer and select the application in which you want to set a default.
From the Select Action menu, select the Toggle/Show All Controls option.
Select the Tab of the application the field exists on.
Select the Control Palette icon and drag and drop a Default Object object to the section the field you want to set the default on exists in.
Highlight the defaultvalue… and select the Control Properties icon.
Enter the attribute for the field you want to set the default value for, this value can be found by looking at the properties for the field. Also enter the default value for the field.
Save and test your application...


APPFIELDDEFAULTS Table

The third method requires the use of a SQL tool. There is an APPFIELDDEFAULTS table in Maximo which allows you to set a default by application, group and/or user. The object and default values are required, but you can then specify a certain app that uses that object or security group or user you want to have a particular default value.
Once your record(s) are inserted in the APPFIELDDEFAULTS table, you will need to restart the Maximo application server for your changes to take effect.
See this IBM technote.


Java

Any example?


Script

If you are running on TPAE 7.5 you have the scripting alternative.
Go To > System Configuration > Platform Configuration > Automation Scripts
Create Script with Object Launch Point.
  • Launch point: ENI-INCNEW - Incident creation
  • Object: INCIDENT
  • Active: yes
  • Events: Add

New Script
  • Script: ENI-INCSITEID - Set default SITEID
  • Script Language: jython

Paste the following script.

from psdi.mbo import MboConstants
mbo.getMboValue("SITEID").setValue("GLOBAL", MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION)



20 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi,

    I need some help on setting a default value on the WO->Plans->Material->Reservation Type.

    I succeeded using the application designer, but got some errors when users would use the select option (goto Inventory and return with value).
    When I removed the default value this error disappeared. So I wanted to do this using the database configuration, so with an upgrade or migration this would automatically be moved to.

    Can you give me more clues or guide me to use the database conf or the appfielddefaults table?

    regards,

    Dave

    ReplyDelete
  3. Don't suppose you know of a way to use the app designer defaultvalue to set a field to null? The sr.affectedperson on createsr defaults to the same as the reported by and I want to force the user to select the value.

    ReplyDelete
    Replies
    1. Hi Kevin,
      Did you ever get an answer on this? I'm stuck on the same question.

      //Kristin

      Delete
  4. there is also a 4th way that is MBO customization

    ReplyDelete
    Replies
    1. You are right!
      Also scripting is available in 7.5.

      Delete
  5. Hi Bruno and colleagues, I am trying to set a default value for the field PRLINE.ORDERUNIT, which is the Measure Unity of a PR Line in the Purchase Requisitions app. Even trying all those methods I am still getting the field empty when creating a new record. Any ideas why this is happening? The value I am entering is a valid measure unit that exists in the DB.

    ReplyDelete
  6. Hi Bruno,

    For the Java paragraph: it is possible to set a default value to a MboSet with the setDefaultValue(String attribute, String value) method. If one would call the add() , addAtEnd() etc. methods afterwards, the default value is set to the new Mbo.

    Also, it should be possible to use setDefaultValue(String attribute, MboRemote mbo from which the value should be derived) according to the 7.5.0.0 javadoc, however I have not tried this myself yet.

    ReplyDelete
  7. Hi Bruno,

    My client needs that historyflag attribute on more search fields dialog on SR Application get a default value ('N'). I added default value from palette control to corresponding section where historyflag exists then configured then save modifications. The thing is that when I get this app from application designer again default value that I configured does not exist like if I did not do anything.
    By the other hand I was searching on lookups, library, etc, xlm export applications, but I didn't found anything.
    Being brief my question is This can be done only through java code?.
    I'm with Maximo 7.5.0.3 version

    Thanks in advance.

    Regards

    ReplyDelete
    Replies
    1. This is difficult to do through configuration as I'm led to believe the java bean class controls this setting. I tired looking at the xml presentation (export the app) - but there is no setting on the historyflag section.

      Delete
    2. This is difficult to do through configuration as I'm led to believe the java bean class controls this setting. I tired looking at the xml presentation (export the app) - but there is no setting on the historyflag section.

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I was able to achieve this by applying a default value on the Advanced Search Section in Application Designer for the SR. It will not work if you try to place the default value on the related section of the more search options popup.

      Delete
  8. What variables are available for a defaultvalue element in the GUI? I would like to set the currently logged in user as the default value for PO.PURCHASEAGENT. thanks, Jeff

    ReplyDelete
  9. Hi Bruno, What ways can be used to set a default value in Maximo 4?

    ReplyDelete
  10. Hi Bruno,
    I am trying to set default value to a dialog box "Select Materials" (which pops up when you press "select materials" button in work order tracking -> Plans tab --> Material sub tab) but it does not seem to work. I am trying to display filters in the dialog box (which I did) and then apply a default value to "ITEMNUM" filter, so that when the dialog box opens up it shows the values already filtered based on the value and then if user wants, he can remove the filter and display all values.

    I added the following statement in the dialog box with id="selectmaterialsonplans" (default value is "BD")



    But it just does not work ! Any idea what could be the reason?

    Thanks...

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I tried to place the exact xml statement in my post but it seems like it's not allowed. But to give you more information, I used the default value control related statement in library.xml but it did not work.. I tried the same for Item look up (in look up.xml) and it worked for item look up but the same is not working in case of dialog box. Not sure why ?

      Delete
  11. This comment has been removed by the author.

    ReplyDelete