Tuesday 13 August 2019

Populating Condition Codes By Just Clicking Condition Code Check Box in Maximo

Recently we had a requirement to add the condition Code on clicking the Condition Code Check box in Item application.

Below is the Code that was written in JavaScript,
Launch Point Type: Attribute Launch Point
Object: Item
Attribute Name: CONDITIONENABLED

importPackage(Packages.psdi.mbo);

var conditioncode  = mbo.getBoolean("CONDITIONENABLED");
var itemconditionSet = mbo.getMboSet("ITEMCONDITION");

if(conditioncode)
{
  for(i=0;i<3;i++)
  {
    var itemcondition = itemconditionSet.addAtEnd();
    if(i == 0)
    {
      itemcondition.setValue("CONDITIONCODE","A");
    }
    else if(i == 1)
    {
      itemcondition.setValue("CONDITIONCODE","B");
    }
    else if(i == 2)
    {
      itemcondition.setValue("CONDITIONCODE","C");
    }
  }
}





But While clicking on the New Row button in Item application, Error message pops up
“BMXAA4157E - The specified value is not a valid Yes or No value. Enter Y, y, or 1 for Yes or N, n, or 0 for No.”


Turn out the field is initially blank and it is trying to execute the automation script. So how to fix the issue.
In the Data base application, set the field “CONDITIONENABLED” with default value.


Create new item. Before saving and check the condition enabled Check box.


 After clicking on the save button the Condition codes are automatically populated.


1 comment: