Maximo Open Forum

 View Only
  • 1.  Copy asset description to asset long description

    Posted 10-06-2023 06:47

    Hi,

    We have a requirement to copy the asset description to asset long description field. I found that longdescription table in db is empty ,so i guess update wont work we will have to use insert.

    I tried inserting, but data is just showing in the database not in the ui. What can be reason of that. I can share the query i am using if required 


    #Administration
    #Analytics
    #EndUser
    #EverythingMaximo
    #Utilities
    #MaximoVisualInspection

    ------------------------------
    Deepa P
    ------------------------------


  • 2.  RE: Copy asset description to asset long description

    Posted 10-06-2023 09:44

    Can you share your SQL statement? That will help troubleshoot possible fixes to your query.



    ------------------------------
    Jason Verly
    Agropur
    ------------------------------



  • 3.  RE: Copy asset description to asset long description

    Posted 10-09-2023 03:28

    Hi Jason,

    I have had shared the query with you. Can you please check and help me out what i am Missing?



    ------------------------------
    Deepa P
    ------------------------------



  • 4.  RE: Copy asset description to asset long description

    Posted 10-09-2023 09:05
    Edited by Pankaj Dubey 10-09-2023 09:06

    Hi Deepa,

    Its seems you forgot to update HASLD column of asset table to 1 because of that you are not able to see the data on front end. Please update 1 in asset table for those record whose description you have inserted in LONGDESCRIPTION table and check after update. If still you are not able to see the data on front please share the insert script.



    ------------------------------
    Pankaj Dubey
    Self Employed
    ------------------------------



  • 5.  RE: Copy asset description to asset long description

    Posted 10-09-2023 10:50

    Here is a script that will do it for you with the Mbos.  It may not be super fast but it will just work through the list of Mbos.  There is a set that is marked discardable to get the list of ids and then another set to actually do the update.  There should only ever be one Mbo in memory at a time so looping through the entire set should be fine as far as performance and memory goes.

    MXServer = Java.type("psdi.server.MXServer");
    MboConstants = Java.type("psdi.mbo.MboConstants");
    
    main()
    
    function main(){
        var assetSet;
        try{
            assetSet = MXServer.getMXServer().getMboSet("ASSET", MXServer.getMXServer().getSystemUserInfo());
            assetSet.setFlag(MboConstants.DISCARDABLE, true);
            var asset = assetSet.moveFirst();
    
            while(asset){
                updateLongDescription(asset.getUniqueIDValue());
                asset = assetSet.moveNext();
            }
    
        }finally{
            _close(assetSet);
        }
    }
    
    function updateLongDescription(id){
        var assetSet;
        try{
            assetSet = MXServer.getMXServer().getMboSet("ASSET", MXServer.getMXServer().getSystemUserInfo());
            var asset = assetSet.getMboForUniqueId(id);
            asset.setValue("DESCRIPTION_LONGDESCRIPTION", asset.getString("DESCRIPTION"));
            assetSet.save();
        }finally{
            _close(assetSet);
        }
    }
    
    function _close(set){
        if(set && set instanceof Java.type("psdi.mbo.MboSet")){
            try{
                set.close();
                set.cleanup();
            }catch(ignored){}
        }
    }
    
    var scriptConfig={
        "autoscript": "MIGRATE.ASSET.DESCRIPTION",
        "description": "Migrate the asset description to the long description field.",
        "version": "",
        "active": true,
        "logLevel": "ERROR"
    };


    ------------------------------
    Jason VenHuizen
    Sharptree
    ------------------------------



  • 6.  RE: Copy asset description to asset long description

    Posted 10-10-2023 20:29

    Hi Deepa,

    I see people have just jumped straight in without asking the question that must be asked. Why?  What is the business need to copy the asset description to the LD?

    There is one premise that I can envision, but let's discuss it first.

    It would seem that each time the asset description is changed, you want that to be copied into the LD.  But now you have the same data in two different places.  This is classed as useless information as the data is overwritten each time the description is changed.

    Do you really want to keep a 'log' of the changes?  You can instead turn on eAudit.



    ------------------------------
    Regards,
    Craig Kokay
    ISW
    Maximo Practice Manager
    eMail: ckokay@isw.net.au
    Phone: +61-411-682-040

    #IBMChampion2023
    ------------------------------