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.
Original Message:
Sent: 02-15-2023 21:52
From: Jonas Fuller
Subject: Multiselect Data Bean & Automation Scripts
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
------------------------------
Original Message:
Sent: 02-10-2023 10:25
From: Jonas Fuller
Subject: Multiselect Data Bean & Automation Scripts
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
Original Message:
Sent: 02-10-2023 09:53
From: Jade Warren
Subject: Multiselect Data Bean & Automation Scripts
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
Original Message:
Sent: 02-10-2023 09:25
From: Jonas Fuller
Subject: Multiselect Data Bean & Automation Scripts
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
Original Message:
Sent: 02-10-2023 05:21
From: Subhransu Sekhar Sahoo
Subject: Multiselect Data Bean & Automation Scripts
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