Thursday 19 November 2020

Display inventory dimensions dynamically in D365

The table must have the field InventDimId and it must have a relation with InventDim. Image 2. Create a new Form. My form has two data sources, InventDimDisplay and InventDim (required) and a grid. Image 3. Set the InventDim data source properties to: Image REPORT THIS AD 4. On form Design, create a new Grid and move the ItemId to your grid and then create a new Group and then set the properties below: Image 5. On class declaration add the following piece of code: 1 2 3 4 5 public class FormRun extends ObjectRun { // Declare the class InventDimCtrl_Frm_EditDimensions InventDimCtrl_Frm_EditDimensions inventDimFormSetup; } 6. Now, create a new method in form. 1 2 3 4 public InventDimCtrl_Frm_EditDimensions inventDimSetupObject() { return inventDimFormSetup; } 7. Override the form’s method Init. 1 2 3 4 5 6 public void init() { super(); // This method will be used to show default fields at form startup element.updateDesign(InventDimFormDesignUpdate::Init); } 8. Create a new method, this method is responsible to show the Inventory Controls. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 void updateDesign(InventDimFormDesignUpdate mode) { InventDimParm inventDimParmVisible; switch (mode) { // Form Init case InventDimFormDesignUpdate::Init : if (!inventDimFormSetup) inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::newFromForm(element); inventDimFormSetup.parmSkipOnHandLookUp( true); // Use the methods on InventDimParm // to set which dimensions to show when form is initialized inventdimparmvisible.inventsiteidflag = true; inventdimparmvisible.InventLocationIdFlag = true; inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible); // Datasource Active case InventDimFormDesignUpdate::Active : inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(InventDimDisplay.ItemId)); //InventDimDisplay is the datasource name. inventDimFormSetup.formSetControls( true); break; // Datasource Field change case InventDimFormDesignUpdate::FieldChange : inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(InventDimDisplay.ItemId)); //InventDimDisplay is the datasource name. InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name inventDimFormSetup.formSetControls( true); break; default : throw error(strFmt ("@SYS54195", funcName())); } } 9. We have to create a method on data source to update our table InventDimId and use the method Active to refresh the controls. Override Data source’s method Active. 1 2 3 4 5 6 7 public int active() { int ret; ret = super(); element.updateDesign(InventDimFormDesignUpdate::Active); return ret; } 10. Now, override the method Modified for ItemId field in your data source. 1 2 3 4 5 6 7 public void modified() { super(); element.updateDesign(InventDimFormDesignUpdate::FieldChange); InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled()); } 11. We have to create a MenuItemButton to call the Display Dimension form where the user can select which dimensions he want to display. Set the following properties: MenuItemType: Display MenuItemName: InventDimParmFixed 12. By the end of this tutorial, your form should look like this. Image 13. The results: Image

Monday 28 September 2020

Use data entity and import through X++ code

EcoResProductV2Entity ecoResProductEntity; NumberSequenceReference numberSequenceReference = EcoResProductParameters::numRefProductNumber(); NumberSequenceTable numberSequenceTable = numberSequenceReference.numberSequenceTable(); NumberSeq numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId); ecoResProductEntity.ProductNumber = numberSeq.num(); ecoResProductEntity.ProductSearchName = _prodIntegrationTable.SearchName; switch (_prodIntegrationTable.ProductType) { case 'Item': ecoResProductEntity.ProductType = EcoResProductType::Item; break; case 'Service': ecoResProductEntity.ProductType = EcoResProductType::Service; break; } switch (_prodIntegrationTable.ProductSubType) { case 'Product': ecoResProductEntity.ProductSubType = EcoResProductSubtype::Product; break; case 'Product Master': ecoResProductEntity.ProductSubType = EcoResProductSubtype::ProductMaster; break; } ecoResProductEntity.RetailProductCategoryName = _prodIntegrationTable.Category; if (ecoResProductEntity.ProductSubType == EcoResProductSubtype::ProductMaster) { ecoResProductEntity.ProductDimensionGroupName = _prodIntegrationTable.ProductDimensionGroup; switch (_prodIntegrationTable.ConfigTechnology) { case "@SYS301180": ecoResProductEntity.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::PredefinedVariants; break; case "@SYS301187": ecoResProductEntity.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::DimensionBased; break; case "@SYS301188": ecoResProductEntity.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::ConstraintBased; break; } ecoResProductEntity.ProductVariantNameNomenclatureName = _prodIntegrationTable.ProdVariantNameNomenclature; ecoResProductEntity.ProductVariantNumberNomenclatureName = _prodIntegrationTable.ProdVariantNumNomenclature; } EcoResProductV2EntityToCrossTableDataAdaptor adaptor = EcoResProductV2EntityToCrossTableDataAdaptor::newFromEntity(ecoResProductEntity); EcoResProduct product = EcoResProductCrossTableManager::makeProductRecord(adaptor); EcoResProductCrossTableManager::insert(adaptor, product); BisProductCreationNPIImportProductCreation::updateEcoResProduct(_prodIntegrationTable, product.DisplayProductNumber); return product;

Wednesday 19 August 2020

Check whether Role is assigned to User or not.


static boolean isUserInRole(Description  _roleName)

    {

        boolean                 res;

        SecurityUserRole        securityUserRole;

        SecurityRole            securityRole;

        ;

        select RecId from securityUserRole

            where  securityUserRole.User    == curUserId()

            join RecId from securityRole

                where  securityRole.RecId == securityUserRole.SecurityRole

                    && (   securityRole.AotName == _roleName

                    )    ;

        if (securityUserRole.RecId)

        {

            res = true;

        }

    

        return res;

    }


====================================================================


   ListEnumerator              userRolesEnumerator;

 userManagement              = new SysUserManagement();

   userRoles                   = userManagement.getRolesForUser(curUserId());

   userRolesEnumerator       = userRoles.getEnumerator();

Global::IsSystemadministrator()

GLobal::FinancialController()

Saturday 1 August 2020

Data Entities Issues

BYOD export failed with the message 'An error occurred in add data flow component for entity store' because of disabled configuration key.
you have the issue search on the lcs project.Tile on the right site you can search for known issues just by copy pasting the error message.you can search for any errors related to FO to see if there is solution

PROBLEM
If an entity field is derived from an extended data type which has disabled configuration key, the configuration key status is not catched during entity refresh and the entity field is marked as enabled. BYOD uses the field because of enabled status but throws the error because the field is really not available.
DESCRIPTION OF CHANGE
The entity refresh process will validate the configuration key status of extended data type recursively in addition to the entity field and data source configuration key.
If any of the data type in entity is not extended with EDT and exported to BYOD the issue rises. I need to change the field data type set to some EDT. Regenerate Staging Table. Delete the entity in  list. Build it . Then Refresh the  entity List using Parameters section. ( If still issue exists try the same by building the model )

Wednesday 8 July 2020

Extend Sales Invoice report

Step 1) Create a new project.

Step 2) Assume that I want to add AdditionalQty field on body of report so I am going to create a extension of SalesInvoiceTmp table and add required fields within it.







Step 3) Build and Synchronize the table.

Step 4) Create a new helper class in my case I have created SalesInvoiceHelper class and copy onInserting event handler of SalesInvoice tmp table. Add logic within the copied event handler.













Note : For the demo purpose I have added logic for this  field. Whereas as  you can add logic as per your requirements.













Step 4) Duplicate the report  and give it a new name. Make changes in design accordingly.



















Step 5)  Go to PrintMgmtDocType class and copy event handler of getDefaultReportFormatDelegate and subscribe to its event handler. Add logic in the method to call this new report in helper class.


























Step 6) Duplicate Sales invoice controller class  by creating new controller and change its logic in order to call your new report.

For instance in my class I have replaced SalesInvoicecontroller instance with salesInvoiceControllerDemo and called my report SalesinvoiceDemo with design Report.


















Step 7)  Extend sales invoice report menu item and change its controller property to your new controller.


Before creating new extension of menu item.











After creating new extension.












Build the complete project and execute your report.

Here comes the error.










Oops. Probably I missed something and that is deploying my report. Right click on your project and select deploy reports.

One more thing go to Account receivable ->Setup -> Form setup -> Select print management
Go to customer invoice node and select your design and report there too.














Final output with our custom column.













http://dynamicsaxtechnicalstuff.blogspot.com/2019/01/customize-design-and-business-logic-of.html