Maximo Open Forum

 View Only
  • 1.  Multiselect Data Bean & Automation Scripts

    Posted 02-09-2023 21:49

    I am looking for a way to replicate the functionality that occurs when a mxevent with a value is called for example (mxevent="dialogok" value="copyServiceItemstoWpSerSet"). The mxevent is on a multiselect data bean dialog that copies data, I am trying to replicate this using an automation script that gets fired using a mxevent="automationscript". I am able to fire the automation script using signatures and the action launch point. Where I run into an issue is when I try to use the mbo of the dialog to find another mbo either by getMbo or using MxServer I am getting this error

    BMXAA4664E - Owner of WPItem/WPMaterial/WpService is not valid.

    I would like to get a handle on the mbo from the dialog mbo. That way I can loop through the selected results of the multiselect data bean and call the .add() method to assign values from the selected values in the dialog. I am trying to add to the WPSERVICE from a view that joins CONTRACT and CONTRACTLINE, if that helps give any context. As well the custom multiselect data bean that I am using is defined in the LIBRARY.xml, and receives data from the view. The automation script's object is the view object. 

    I am new to using the service.webclientsession(), resultsbean, Multiselectdatabean, and I am open to suggestions for better solutions. 


    #Customizations
    #EverythingMaximo

    ------------------------------
    Jonas Fuller
    Serco NA
    ------------------------------


  • 2.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-10-2023 05:21

    Hi Jonas,

    I can see your requirement is to copy the selected data from a multiselect bean (which is a view of contract and contractline) and add it to the WPSERVICE view. 

    I don't think you can directly add to WPSERVICE/WPMATERIAL views as their owners are either WORKORDER or WOACTIVITY. So first you need to obtain owner mbo (either woactivity or workorder) in your script, get the wpservice set by using that owner mbo and then add the data selected from multiselect databean to the wpservice by calling the add method.

    by d way in which application you are accessing the dialog box? let me know how you are progressing to achieve this.



    ------------------------------
    Subhransu Sekhar Sahoo
    Tata Consultancy Services
    ------------------------------



  • 3.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-10-2023 09:25

    Thanks for the suggestions, the application that I am calling the dialog box from is the workorder this opens a dialog box located in the LIBRARY.xml. Is there a way to get the handle on the parent mbo that the dialog box is called from? 



    ------------------------------
    Jonas Fuller
    Serco NA
    ------------------------------



  • 4.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-10-2023 09:53

    You could consider putting the "action button" in the dialog inside a section with datasrc="mainrecord" like this (note that I put "comments" in the example XML):

        <dialog id="my_multi_select" label="Select Planned Service Records" savemode="onunload"> ## have the data source for this be the joined view
            <table id="service_table" inputmode="readonly" label="Services" selectmode="multiple"> ## allows multi-select
                <tablebody displayrowsperpage="6" filterable="true" id="services_tablebody">
                    <tablecol filterable="false" id="selectsvc" mxevent="toggleselectrow" sortable="false" type="event"/>

                   ## table columns here
                </tablebody>
            </table>
            <section>
                <sectionrow id="sr1">
                    <sectioncol id="sc1">
                        <section id="act_section" datasrc="mainrecord" > ## note that this section is in the context of the MAIN WORK ORDER
                            <buttongroup id="act_bg">
                                <pushbutton id="multi_act" label="Add Selected Records" mxevent="YOUR_ACTION_SCRIPT_SIG_OPTION_HERE"/>
                            </buttongroup>                
                        </section>
                    </sectioncol>                
                    <sectioncol id="sc2">
                        <section id="can_section"> ## note that this section is in the context of the DIALOG
                            <buttongroup id="can_bg">
                                <pushbutton id="multi_can" label="OK" mxevent="dialogcancel"/>
                            </buttongroup>                
                        </section>
                    </sectioncol>                
                </sectionrow>
            </section>
        </dialog>

    Then, you could have your script include something like this:

    ## get the target set(s)
    target_set = mbo.getMboSet("WPSERVICE"); ## or whatever the right destination is
                                             ## because this script is fired from the
                                             ## button in the section with datasrc="mainrecord"                                         

    ## get the selected records
    session = service.webclientsession();
    databean = session.getDataBean("BEAN_DATA_SOURCE_ID_HERE");
    set = databean.getMboSet();
    selection = set.getSelection();

    ## add the selected records
    for svc in selection:
        new_svc = target_set.add();
        ## do your setValues here...
        new_svc.setValue("ATTRIBUTE", "VALUE", Flags);
        
    service.closeDialog(); ## if you have savemode="onunload" I think it'll save the added services



    ------------------------------
    Jade Warren
    Great River Energy
    ------------------------------



  • 5.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-10-2023 10:26

    The definition of the dialog

    <dialog beanclass="psdi.webclient.system.beans.MultiselectDataBean" id="testitems" label="Test Items" parentdatasrc="MAINRECORD" relationship="...
    Already has the parentdatasrc equals MAINRECORD, which is the workorder object since it finds the data to display in the table from the relationship attribute. 
    The buttons are inside this dialog definition, yet when the script is fired it seems the mbo.getMboSet("WPSERVICE") is trying to assign the owner to the data feed which is the view. Not the parentdatasrc MAINRECORD. I will try wrapping the action button in a section with the datasrc attribute. Thank you for the suggestions.


    ------------------------------
    Jonas Fuller
    Serco NA
    ------------------------------



  • 6.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-15-2023 21:52

    Thanks for all the suggestions, I ended up limiting the number of records shown on the multi-select data bean to ones that meet the requirements. It is using the of the box (mxevent="dialogok" value="copyServiceItemstoWpSerSet") event that maps generic service items to the WPService. Then on save of the WO use an automation script to map the specific data from a view that shows the identical records that were in the multi-select data bean previously. Essentially mimicking the process I wanted to do with a data bean mapping, but using an automation script to move data.



    ------------------------------
    Jonas Fuller
    Serco NA
    ------------------------------



  • 7.  RE: Multiselect Data Bean & Automation Scripts

    Posted 02-17-2023 11:48

    Hi Jonas,

    years ago I did a similar kind of requirement in one of my assignment(Maximo 7.6.0.2 I think) where I wrote two automation scripts. One on initialization of dialog box (i.e the databean where we selected multiple records to be added) wherein I used to set the owner (which was Workorder in my case) modified by using the setModified() method internally,

    then in the owner's beforesave (i.e WO.beforesave) I wrote the copying logic from one custom object to another.

    In my case, the dialog box was also loaded from a custom object. 



    ------------------------------
    Subhransu Sekhar Sahoo
    Tata Consultancy Services
    ------------------------------