Maximo Open Forum

 View Only

 Automation script not working in upgrade (7.6.1.0 to 7.6.1.2)

  • Customizations
Jennifer Romeiser's profile image
Jennifer Romeiser posted 03-11-2022 13:57

We are in the process of implementing an upgrade in our Maximo Dev Environment. We are currently on version 7.6.1.0 (004) and going to TPA 7.6.1.2.

This is 1 of the 2 issues (#2) that we came across. We are a new support team with very limited knowledge and would appreciate any guidance.


After upgrade, we are unable to return rotating assets due to error BMXAA8108E - The status of this asset cannot be changed from Decommissioned. The asset was returned to the vendor.

Steps:

Select a PO to return an asset in Receiving app

Selected "Select Rotating Assets for Return" and select the asset you want to return to vendor.
This SHOULD update the receipt to show the asset is outstanding again AND the asset record will show as status "RETURN". but in DEV env this fails.

Under System Configuration > Platform Configuration >Automation Scripts - found a script that is being used.

We verified this when we put ADMIN MODE ON. We did not receive the error, and the status was "PENDING DECOM". Support stated that it is working correctly and will not provide any support on this customization.

I have attached the code. Any help would be greatly appreciated. 

Jason VenHuizen's profile image
Jason VenHuizen
The error you are receiving is a valid Maximo error given what you are trying to do.  The logic is that if the current status of the asset is DECOMMISSIONED and the RETURNTOVENDOR flag is true then you are going to get that error.  You could avoid that by setting the RETURNTOVEDOR flag to false or by forcing the status to something other than DECOMMISSIONED before you run the transaction, but both of those may not have other ramifications, depending on what you are doing.

There are a number of other minor problems with the code you provided so I have gone ahead and rewritten it with comments to explain the differences.

Since you are going from Java 7 to Java 8 you might want to look at:

https://www.sharptree.io/blog/2021/2021-10-28-js-nashorn-vs-rhino/

If you have any questions feel free to reach out.

- Jason


// Here is how to do this in Nashorn without the compat library
MXServer = Java.type("psdi.server.MXServer");

// structure so you an return properly.
main();

function main() {
    //if you are going to check if the Mbo is null do it early otherwise calling getUserInfo() is going to throw an exception
    if (typeof mbo !== 'undefined' && mbo && mbo.getMboValue("RETURNEDTOVENDOR").isModified() && mbo.getBoolean("RETURNEDTOVENDOR")) {
        // get the asset set from the mbo without having to fetch it separately
        var woAssetSet = mbo.getMboSet("$relatedasset", "ASSET", "assetnum = :assetnum and siteid =:siteid")

        // check if the returned set has any records.
        if (!woAssetSet.isEmpty()) {
            woAssetMbo = woAssetSet.getMbo(0);

            // Note the parameters here.  The first is the new location, which "RETURN ASSET TO VENDOR" seems more like the memo
            // moveAssetWithinInventory(String newLocation, String memo, Date dateMoved, String newBinnum, String ponum, String glCreditAcct, String glDebitAcct, String matRecTransID);
            woAssetMbo.moveAssetWithinInventory("NEWLOCATION","RETURN ASSET TO VENDOR", MXServer.getMXServer().getDate(), "", "", "", "", "");
            woAssetMbo.changeStatus("RETURN", false, true, true, true);
            // no need to save, because the woAssetMbo is part of the current transaction and will be saved when the transaction saves.
        }

    }
}​