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
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
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.
Brillant post!
ReplyDelete