Hi everyone,
I add a form with datasource CustConfirmJour and add a combobox with field(language) and checbox(additional comment in report). When i change a language it's works but always print a SalesConfirm for the first SalesOrder.
Method Init
public void init() { if(!element.args() || !element.args().record()) { throw error("@SYS302"); } super(); if(element.args().record().TableId == tableNum(CustConfirmJour)) { CustConfirmJourLocal = element.args().record(); } }
Method closeOK
public void closeOk() { Args args = new Args(); RecordSortedList journalList = SalesConfirmJournalPrint::construct().newJournalList(); for (CustConfirmJourLocal = getFirstSelection(custConfirmJour_ds); CustConfirmJourLocal; CustConfirmJourLocal = custConfirmJour_ds.getNext()) { journalList.ins(CustConfirmJourLocal);} journalList.first(CustConfirmJourLocal); args.record(CustConfirmJourLocal); new MenuFunction(menuitemOutputStr(SalesConfirmation), MenuItemType::Output).run(args); super(); }
*This post is locked for comments
Thank's you all for help.
I add this code to the method init in DataSourcea and work's.
public void init() { QueryBuildDataSource queryDataSourceLink; ; super(); if (element.args().dataset() == tablenum(CustConfirmJour)) { this.query().dataSourceTable(tablenum(CustConfirmJour)).clearDynalinks(); queryDataSourceLink = this.query().dataSourceTable(tablenum(CustConfirmJour)).addDataSource(tablenum(CustConfirmSalesLink)); queryDataSourceLink.relations(true); queryDataSourceLink.addDynalink(fieldnum(CustConfirmJour, ConfirmId), element.args().record(), fieldnum(CustConfirmJour, ConfirmId)); } }
Put a breakpoint on main method of SalesConfirmController class and check values of passed args.
Debug and check where value is getting reset to first record.
public void closeOk() { Args args = new Args(); RecordSortedList journalList = SalesConfirmJournalPrint::construct().newJournalList(); MultiSelectionHelper helper = MultiSelectionHelper::construct(); helper.parmDatasource(custConfirmJour_ds); CustConfirmJourLocal = helper.getFirst(); while (CustConfirmJourLocal.RecId != 0) { info(CustConfirmJourLocal.SalesId); journalList.ins(CustConfirmJourLocal); CustConfirmJourLocal = helper.getNext(); } // journalList.first(CustConfirmJourLocal); args.object(journalList); new MenuFunction(menuitemOutputStr(SalesConfirmation), MenuItemType::Output).run(args); super(); }
Display the same error.
When i comment journalList.first(CustConfirmJourLocal) work but still print a SalesOrder S0000002. I select a SalesOrder S00000512
Move the journalList.ins(CustConfirmJourLocal) statement before helper.getNext() statement statement inside loop
When i use this code
public void closeOk() { Args args = new Args(); RecordSortedList journalList = SalesConfirmJournalPrint::construct().newJournalList(); MultiSelectionHelper helper = MultiSelectionHelper::construct(); helper.parmDatasource(custConfirmJour_ds); CustConfirmJourLocal = helper.getFirst(); while (CustConfirmJourLocal.RecId != 0) { info(CustConfirmJourLocal.SalesId); CustConfirmJourLocal = helper.getNext(); } journalList.ins(CustConfirmJourLocal); journalList.first(CustConfirmJourLocal); args.object(journalList); new MenuFunction(menuitemOutputStr(SalesConfirmation), MenuItemType::Output).run(args); super(); }
I have this error
In the above code, you are selecting only the first marked record using helper.getFirst()
To select the other marked records, you have to run a loop and use helper.getNext() to get the next marked record.
You can find this in the link which i posted with my previous comment.
In init metod i deleted this code.
I Tried to use MultiSelectionHelper and always select the same Sales Order I don't know why.
public void closeOk() { Args args = new Args(); RecordSortedList journalList = SalesConfirmJournalPrint::construct().newJournalList(); MultiSelectionHelper helper = MultiSelectionHelper::construct(); helper.parmDatasource(custConfirmJour_ds); CustConfirmJourLocal = helper.getFirst(); journalList.ins(CustConfirmJourLocal); journalList.first(CustConfirmJourLocal); args.object(journalList); new MenuFunction(menuitemOutputStr(SalesConfirmation), MenuItemType::Output).run(args); super(); }
I use a similar code to the CustInvoiceJour and it's works.
Hi Krychul,
Try using MultiSelectionHelper class to select marked records.
You can find an example in the below link:
community.dynamics.com/.../get-select-records-by-multiselectionhelper-class
You need to debug you method and look if all your marked records are selected and added to journalList.ins(CustConfirmJourLocal); then you need to check if correct record is selected in journalList.first(CustConfirmJourLocal);
and why do you need
if(element.args().record().TableId == tableNum(CustConfirmJour))
{
CustConfirmJourLocal = element.args().record();
}
in init method ?
When i mark or not mark records always print SalesConfrim from SalesOrder(SO0000002)
André Arnaud de Cal...
292,111
Super User 2025 Season 1
Martin Dráb
230,934
Most Valuable Professional
nmaenpaa
101,156