Pages

February 12, 2012

Set an attribute as required with no default value

This post describes how to set an object attribute as mandatory without providing a default value. This is to circumvent what it seems to be a TPAE limitation that prevents to do this from the standard Database Configuration application.
Lets make an example. The out-of-the-box attribute PO.VENDOR (Purchase Order - Vendor) is not mandatory. Unfortunately if you try to set as required using the Database Configuration application you will get the following error.


However, if you look into other PO attributes you will find many of these (CHANGEBY, ORGID, etc.) that are defined as required but have no default value. This means that Maximo is internally capable of handling this case.
To circumvent this restriction I use the procedure described hereafter.

Ensure there are no null values in the desired field. This is important because otherwise the configdb will fail with the error: Assignment of a NULL value to a NOT NULL column "VENDOR" is not allowed.
These are two sample SQL statements that can be used to check null values and to set a dummy value in these rows.
select * from PO where VENDOR is null;
update PO set VENDOR='...' where VENDOR is null;

Set the attribute and provide a dummy default value using the Database Configuration. Save your changes without applying the configuration. Do not run configdb!
Locate the PO.VENDOR row in the MAXATTRIBUTECFG table and clean the DEFAULTVALUE field.
Refresh the Database Configuration list view and check the definition of the PO.VENDOR attribute. It should now be listed as 'To be changed' and defined as required but without a default value.
Run configdb script of apply the configuration changes using the action menu.
Now open the Purchase Orders application and you will see the Company field marked with an asterisk.


NOTE: I have used this procedure many times but I do not guarantee it always works on every possible database server. Never do this in a production environment without testing it on your development environment!

2 comments:

  1. Dear Bruno,
    I have a similar problem with required Field without default value. I use maximo 7.5.0.4.
    I want to set MR.RequestedFor field as Required Field but without a default value. I see that this field is allowed to be NULL, I try to use Default Value Controls from Application designer but its not working, its looks like overwritten internally. Do you have any suggestion for me??? :(

    ReplyDelete
    Replies
    1. Probably there is a custom class attached to the MR.RequestedFor field.
      You should override the init method.
      Or you could also try so clear the default value with a TPAE script.

      Delete

Note: Only a member of this blog may post a comment.