11.04.2019, 20:12 | #1 |
Участник
|
stoneridgesoftware: Create Custom Dialog on Form with Customer Lookup for a Specific Financial Dimension in D365 FinOps
Источник: https://stoneridgesoftware.com/creat...n-d365-finops/
============== Recently I had a request to create a custom form in Dynamics 365 Finance and Operations. One requirement was that prior to the form opening, it would prompt the user for a date (defaulted in with the current date) and a value from a specific financial dimension. The working prompt form would look like this (with the custom lookup code on the financial dimension): So, here’s how I would a custom dialog on a form with a customer lookup for a specific financial dimension in D365 FinOps. The dialog code itself is not hard to do. It simply is placed in the init() method of the main form: /// /// Build the dialog that prompts the user for a date and a site to process /// public void init() { super(); // build the dialog for prompt Dialog dialog = new Dialog("Label goes here",element); DialogField dfDate = dialog.addField('Date1980','Date'); dfDate.value(DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone())); DialogField dfDimValue = dialog.addField('DimensionValue','LocationSite'); FormBuildStringControl control; control = dfDimValue.control(); // use the custom lookup control.registerOverrideMethod('LookUp','dimLookup',this); // if we click OK, we run, otherwise, close the form if (dialog.run()) { dlDate = dfDate.value(); dlDimValue = dfDimValue.value(); boolean dlClosed = dialog.closedOk(); if (dlClosed) { // code does in here } } else { element.close(); } }This key line in the code above is the following: control.registerOverrideMethod('LookUp','dimLookup',this);This line allows us to override the lookup method of the control in the dialog, and replace it with our custom code. This method exists on the form as well. /// /// This is the custom lookup code for the LocationSite financial dimension field on the user prompt dialog /// /// private void dimLookup(FormStringControl _control) { Query query = new Query(); QueryBuildDataSource qbdsDimensionFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag)); QueryBuildRange qbrFinancialTagCategory = qbdsDimensionFinancialTag.addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)); qbrFinancialTagCategory.value(strFmt('%1', DimensionAttribute::findByName(dimName, false).financialTagCategory())); SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(DimensionFinancialTag), _control,true); sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value), true); sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description)); sysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag, FinancialTagCategory)); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }This is pretty standard lookup code using the SysTableLookup class. That is all that is needed to accomplish my requirements (other than some specific requirement code that is not relevant here). You can use this method to create any custom dialog form opening and have a customer lookup for any specific financial dimension in D365 Finance and Operations. If you have any more questions on how to do this yourself, please contact us here at Stoneridge Software. Источник: https://stoneridgesoftware.com/creat...n-d365-finops/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|