16.05.2018, 15:11 | #1 |
Участник
|
stoneridgesoftware: Creating a List Panel for a Field Lookup in Dynamics AX
Источник: https://stoneridgesoftware.com/creat...n-dynamics-ax/
============== I recently had a scenario where we had to create a new vendor attribute that could have one or more values assigned to a vendor. The requirement wanted a drop-down field that opened a form and showed which values had been selected and which ones are still available. The lookup form should also allow the user to add/remove values. I was able to use an extension of the SysListPanel to accomplish this. I referenced form SysUserGroupInfo (Sys admin > Users > User groups). There are also list panels specific for financial dimensions. Form DimensionFocus (General ledger > Chart of accounts > Dimensions > Financial dimension sets) is an example. Here’s how you would go about creating a list panel for a field lookup in Dynamics AX. Prerequisites
Lookup form: 1. I used the Custom patter type since this form really won’t have any grids, action pain, etc. I set the Style property to Lookup and set the Show Delete / New Button to No. These properties are on the Design. 2. I set the auto declaration of the tab page control to Yes. 3. Add a datasource. This will be the new table that is created to store the new attribute values. There is very little coding needed for this. You need to override the Init and close methods of the form and I created a Validate method. You will need to override the Active method of the datasource as well. There is very little coding needed for this. You need to override the Init and close methods of the form and I created a Validate method. You will need to override the Active method of the datasource as well. Override the init method of form 1. In the init method is where you initialize the SysListPanel. I used the SysListPanelRelationTableCallBack public void init() { // create new panel that will show the selected and available categories sysListPanel = SysListPanelRelationTableCallback::newForm(element, element.controlId(formControlStr(SSIVendCategoryValueTable, vendCategoryValue)), "@SYS24159", "@SYS30545", 0, //#ImageUser, tablenum(SSIVendCategoryValueTable), fieldnum(SSIVendCategoryValueTable, CombinedCode), fieldnum(SSIVendCategoryValueTable, CombinedCode), tablenum(SSICategoryValueTable), fieldnum(SSICategoryValueTable, DeptCatCode), [fieldnum(SSICategoryValueTable, DeptCatCode), fieldNum(SSICategoryValueTable, DepartmentCategoryDesc)], 0, '', identifierstr(Validate), '', ''); super(); //set the record from the caller ssiVendCategoryValueTableRec = element.args().record(); sysListPanel.init(); }2. Details of SysListPanelRelationTableCallback::newForm()
Override the close method of form All that I put in the close method of the form is a call to the finalize method of the list panel. This will ensure all actions have been completed of the list panel to help ensure no errors occur when the form closes. public void close() { sysListPanel.finalize(); super(); } New validate method I didn’t need any special validation for this solution. I just return a true value. This is similar to how the sysUserGroupInfo form does it. boolean validate(userId _userId, AddRemove _addRemove, SysListPanelRelationTable _listViewHandler) { return true; } Override the active method of datasource This is where I added the ranges for the list panel and also where the call to fill the list panel happens. We need to make sure that we are only returning the new attribute values for the vendor that has been selected in the caller form. [DataSource] class SSIVendCategoryValueTable { /// /// active method for datasource SSIVendCategoryValueTable /// /// /// int /// public int active() { int ret; ret = super(); // set parms for range field and value sysListPanel.parmRelationRangeField(fieldNum(SSIVendCategoryValueTable, Vendor)); sysListPanel.parmRelationRangeValue(ssiVendCategoryValueTableRec.Vendor); sysListPanel.fill(); return ret; } } Tab page method allowPageDeactivate The last piece of coding on the form is to add some logic to the allowPageDeactivate of the tab page control. This will handle any updates that are needed based on changes made to the list panel. [Control("TabPage")] class vendCategoryValue { /// /// saves any changes made to record values /// /// /// boolean /// public boolean allowPageDeactivate() { boolean ret; ret = super(); // create new record if one doesn't already exists if (!SSIVendCategoryValueTable.RecId) { if (SSIVendCategoryValueTable_ds.validateWrite()) { SSIVendCategoryValueTable_ds.write(); } else { return false; } } return ret; }That is all the coding that is needed for this functionality. The List panel will handle adding/removing any records from the tables. After all of this, you get something like the below. When you click the drop down of the new vendor attribute field the lookup form appears. You can use the left/right arrows to add/remove values. The selected values are the records that are stored in the new table created in the prerequisites. It will store the value and the vendor. The values listed in the Available are from the table of the new EDT. Источник: https://stoneridgesoftware.com/creat...n-dynamics-ax/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|