Microsoft_MVP_banner

D365FO – Start hierarchy approval with specific worker

D365FO - Start hierarchy approval with specific worker

There are times when clients want to start hierarchy approval from a specific worker and not from the one who initiated the workflow and then traverse up the hierarchy. Scenario: Invoices are coming from third-party into FinOps and creating tax invoice registers Setting the Approved by field at tax invoice register line level AP Clerk/Administrator assigns these invoices to correct worker for approval So, in the above scenario, the AP clerk initiated the workflow but the workflow will not go his/her line manager for approval instead it will be assigned to the owner (approved by) of the invoice. This is what we want to achieve – add a new Start from This Start from list get populated through getSupportedDataType() in  class WorkflowHierarchyProviderHelper Create a new event handler class and subscribe to the delegate as shown below. P.S. WFOwner is the custom created EDT. class ECL_WorkflowHierarchyProviderHelperEventHandler {     [SubscribesTo(classstr(WorkflowHierarchyProviderHelper), delegatestr(WorkflowHierarchyProviderHelper, addAdditonalSupportedDataTypesDelegate))]     static void addAdditonalSupportedDataTypesDelegate(Set _supportedDataTypes)     {         _supportedDataTypes.add(extendedTypeStr(WFOwner));     } } Add a new field on LedgerJournalTable and assign the WFOwner EDT to it. LedgerJournalTable is for reference as the above change is implemented for vendor invoice approval.

D365FO – Add new participant and type of participant to Participant workflow element

D365FO - Add new participant and type of participant to Participant workflow element

There are times when you want to add a new type of participant other than security role participants and user group participants, this post describes the steps to take and achieve this requirement. This is the final output Let’s find out how did it work. This is how each type of participant exists in AOT so a new Workflow Participant Assignment Provider needs to be created in order to see it in the Type of participant list as for this example ‘Vendor invoice approval provider’ is being added. Created a new Workflow Participant Assignment Provider with the following properties. Available For All Workflow Templates = No [Just want to have this new Participant type vendor invoice approval workflow] Added new workflow type and link it with VendInvoiceApprovalJournalTemplate which is the workflow type name for Vendor tax invoice approval journal workflow  Each provider has a Provider class and here is an example of the class used for above created participant provider class FF_VendInvoiceWFParticipantProviderExpend  extends WorkflowParticipantProvider_Expend {     const str owner = ‘OWNER’;     public WorkflowParticipantExpenDocumentType documentType()     {         return WorkflowParticipantExpenDocumentType::VendInvoice;     }     public WorkflowParticipantTokenList getParticipantTokens()     {         WorkflowParticipantTokenList tokenList = WorkflowParticipantTokenList::construct();         tokenList = super();         tokenList.add(owner, ‘@SYS77709’);         return tokenList;     }     /// <summary>     ///     Resolves the vendor invoice line dimensions to a list of users     /// </summary>     /// <param name=”_context”>     ///     An instance of the <c>WorkflowContext</c> class     /// </param>     /// <param name=”_participantTokenName”>     ///     The participant token that is selected for a role-based assignment.     /// </param>     /// <returns>     ///     An instance of the <c>WorkflowUserList</c> class that contains the enabled users from the token     /// </returns>     /// <exception cref=”M:Exception::Error”>     ///     Participant token does not exist     /// </exception>     public WorkflowUserList resolve(WorkflowContext _context, WorkflowParticipantToken _participantTokenName)     {         LedgerJournalTable ledgerJournalTable = this.getLedgerJournalTableFromContext(_context);         WorkflowUserList userList = WorkflowUserList::construct();                 if (_participantTokenName == owner)         {             userList.add(DirPersonUserEx::worker2UserId(LedgerJournalTable::findRecId(_context.parmRecId()).FF_Originator));         }         return userList;         }         /// <summary>     /// Gets the <c>LedgerJournalTable</c> record from the workflow context.     /// </summary>     /// <param name = “_context”>The workflow context.</param>     /// <returns>A <c>LedgerJournalTable</c> record.</returns>     private LedgerJournalTable getLedgerJournalTableFromContext(WorkflowContext _context)     {         LedgerJournalTable ledgerJournalTable;         if (_context.parmTableId() == tableNum(LedgerJournalTable))         {             ledgerJournalTable = LedgerJournalTable::findRecId(_context.parmRecId());         }         else if (_context.parmTableId() == tableNum(LedgerJournalTable))         {             ledgerJournalTable = LedgerJournalTrans::findRecId(_context.parmRecId(), false).ledgerJournalTable();         }         return ledgerJournalTable;     }     /// <summary>     /// Validates that the <c>WorkFlowContext</c> has the expected tables.     /// </summary>     /// <param name = “_context”>The workflow context.</param>     /// <returns>true if the expected tables are found; otherwise, false.</returns>     private boolean doesContextHaveExpectedTable(WorkflowContext _context)     {         return _context.parmTableId() == tableNum(LedgerJournalTable) || _context.parmTableId() == tableNum(LedgerJournalTrans);     }     public static FF_VendInvoiceWFParticipantProviderExpend construct()     {         return new FF_VendInvoiceWFParticipantProviderExpend();     } } If your interested to know how it used to work in AX 2012, follow this link https://dynamicsnavax.blogspot.com/2009/12/ax-workflow-direct-approver.html

D365FO – How not to select Fleet Management modules in package creation

Want assurance that you never select/include fleet management modules in package creation or build all module together. Just rename the Descriptor folder from all these three locations and refresh models in VS first time to reflect the changes.<Service volume drive>:AosServicePackagesLocalDirectoryFleetManagement<Service volume drive>:AosServicePackagesLocalDirectoryFleetManagementExtension<Service volume drive>:AosServicePackagesLocalDirectoryFleetManagementUnitTests

D365FO – Get list of obsolete data entities

Find which data entity is obsolete after every new update. Here are the steps. For example; Customers V2 data entity is obsolete with version 8.0 For developers: Type the below in the metadata search in VSTS: type:dataentityview property:isobsolete=yes

D365 platform update 12 (7.3): Admin access changes

The Microsoft team did release platform update 12 for Dynamics 365 for Finance and Operations, Enterprise Edition 7.3. There have been few changes concerning accessibility (admin access on VMs). Starting with platform update 12 users do not have admin access to D365 VMs hosted on the Microsoft subscription. Which means: 1.    You can only log in with the “builtinUserxxxxxxxxx” account and not the “builtinaxlocaladmin” account anymore. Prior to PU12 7.3 With PU12 7.3 2.    IIS Express is used as the web server instead of IIS 3.    IIS Express runs when Visual Studio is running  4.    Visual Studio cannot be run as Administrator anymore (you are not the local admin anymore on your development VM L ). Just double click Visual Studio shortcut or run it from start. Admin access to development virtual machines can only be achieved with following options; 1.    Host a development VM on a separate Azure subscription 2.    Deploy VM with an older platform update than PU12 and then upgrade platform update (This option will not work for 7.3) Reference: https://community.dynamics.com/ax/b/newdynamicsax/archive/2018/01/05/restricted-admin-access-on-development-vms-with-platform-update-12-what-you-need-to-know

D365FO: How to debug a non-development and a non-production environment

This post outlines the steps how to debug an issue which is happening in non-development or non-production environments e.g. UAT environment. 1.    RDP to your environment where you want to debug the issue, with this example I am connecting to UAT (Sandbox).  2.    Connect to SQL server a.     Get the server name from LCS database accounts b.    Use .database.windows.net to connect to database 3.    Create a new SQL sign-in that the developer can use. This step lets the system administrator maintain the security of the sandbox environment. The developer will have access to one database for only a limited time. Use the following code to create the new SQL sign-in. CREATE USER devtempuser WITH PASSWORD = ‘pass@word1’ EXEC sp_addrolemember ‘db_owner’, ‘devtempuser’ 4.    Stop following services in development box a.     IIS or world wide web publishing service development box b.    Microsoft Dynamics 365 unified Operations: Batch Management service 5.    Go to J:AosServiceWebRootweb.config. 6.    Save a copy of the original web.config file, so that you can switch back later. I copied file in the same directory and renamed the web.config to webDev.config and copied one to web.config 7.    Edit the following section in the web.config file. Before your changes <add key=”DataAccess.Database” value=”AxDB” /> <add key=”DataAccess.DbServer” value=”devDbServerName” /> <add key=”DataAccess.SqlPwd” value=”password” /> <add key=”DataAccess.SqlUser” value=”axdbadmin” /> After your changes <add key=”DataAccess.Database” value=”sandboxdatabaseServerName” /> <add key=”DataAccess.DbServer” value=” sandboxdbName.database.windows.net” /> <add key=”DataAccess.SqlPwd” value=”P@ssw0rd” /> <add key=”DataAccess.SqlUser” value=”devtempuser” /> 8.    Start IIS or world wide web publishing service 9.    Do not start batch service otherwise your batch jobs of development box will start writing into UAT environment. Be careful with this step!!! 10.  Now, connect to your development box from browser. Oops!!! It does not connect and throw an error. Don’t worry let’s jump into event log and see what’s in there Okay; so it is an access issue and here is the resolution for it. 11.  Execute the following command against Master database in UAT database server. IP address you get from the event viewer. exec sp_set_firewall_rule N’PPDEV01′, ‘13.70.85.22’, ‘13.70.85.22’ Note: Restart IIS and make sure application pool is started 12.  Connect to development URL again from browser and this time it works. You can now access UAT database (all legal entities etc.) 13.  Restart or your start your VS in development box and attach to Process w3wp.exe to troubleshoot the issue(s) Done with your debugging and got the resolution J 14.  Now it is time to remove devtempuser from UAT database, this prevents having the permanent access to the sandbox database. Right-click on the devtempuser user under Sabndoxdatabase | Security | Users and delete it. 15.  Stop IIS. 16.  Revert changes from the web.config file or simply delete the copied one and rename the original one from WebDev to Web. 17.  Start IIS. 18.  Start batch service  19.  Connect to development environment URL and make sure it is connected to development database. Reference:  https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/debugx-issue-against-copy-of-production

Read excel through X++ in D365FO

Sample code to read an excel file, all it need file stream as a parameter. public boolean importFromExcelfiles(System.IO.Stream _stream) {    OfficeOpenXml.ExcelWorksheet        worksheet;    OfficeOpenXml.ExcelRange            cells;    OfficeOpenXml.ExcelPackage          package = new OfficeOpenXml.ExcelPackage(_stream);            int totalRows,totalCells,rowCounter,cellCounter;    if(package)    {       worksheet       = package.get_Workbook().get_Worksheets().get_Item(1);       cells           = worksheet.Cells;       totalRows       = worksheet.Dimension.End.Row ;       totalCells      = worksheet.Dimension.End.Column;       for (rowCounter = 2; rowCounter<= totalRows; rowCounter++)       {           for (cellCounter=1; cellCounter<=totalCells; cellCounter++)           {               //Do something with the values               info(cells.get_Item(rowCounter, cellCounter).value);           }       }    }    return true; } This method can be called like this; FileUploadTemporaryStorageResult    fileUploadResult; fileUploadResult = FileUploadControl.getFileUploadResult(); public void importFromFile() {     if(fileUploadResult)     {         using(System.IO.Stream stream  = fileUploadResult.openResult())         {             Filename    filename;             if(stream)             {                 try                 {                     filename = fileUploadResult.getFileName();                     if(this.importFromExcelfiles(stream))                     {                         info(strFmt(“File %1 has been imported successfully”, filename));                     }                 }                 catch(Exception::Error)                 {                     warning(“File import failure”);                 }             }         }     } }

D365FO – Method wrapping and chain of command

Another most awaiting Extensibility feature (Chain of Command) is going to come with one of the next platform updates.  This enables you to call/use protected members and methods without making them hookable and using pre/post event handlers.  More details are here https://blogs.msdn.microsoft.com/mfp/2017/07/04/extensible-x-chain-of-command/ and also here https://roadmap.dynamics.com/?i=296a1c89-ce4e-e711-80c0-00155d2433a1#.WVw1llbSw-M.linkedin Stay tuned on above road map site to find more on this feature.

FaisalFareed@2025. All rights reserved

Design by T3chDesigns