Wednesday, November 23, 2022

D365 FO Finance and Operations : AOT Browser

 

 In Dynamics 365 Finance and Operations the AOT is not accessible from the user interface

It is only available in a development box using Visual Studio



In Dynamics AX 2012 and earlier it was possible for power users to be able to open and browse the contents of the AOT (Application Object Tree) from the UI. This functionality was removed in Dynamics 365 for Finance and Operations as all development is now done in Visual Studio. This means that in order to browse the contents of the AOT, one now needs access to a development environment with Visual Studio.

AOT Browser to save the day! With the AOT Browser it is now possible to browse the objects in the AOT from the D365FO web interface.  Arbela Technologies , who is one of the top Microsoft partners, has developed an enhancement that has basically replicated the old AOT user experience right in the Dynamics 365 Finance and Operations application. Arbela is giving this out for free on GitHub which is so awesome!

How To Get The AOT Browser

The AOT Browser is available for free on GitHub here.   Click on the “Releases” link.


After you have deployed the AOT Browser you will need to run the “Populate AOT objects” job. This job will populate the list of objects in the AOT. 

To check how to D365 F&O Install a deployable packagefrom command line / Apply the latest platform update to environments

It is recommended to run this as a recurring batch job because the initial run may take a few minutes and you will want to keep the AOT up to date for any modifications you make to Dynamics 365 Finance and Operations.

To do this Navigate to the AOT Browser workspace on the homepage.


From here click the “Populate AOT objects”.

Open Table Browser

1. Select the table or view you wish to browse the data for and select “Open table browser”



View Source Code

At the top of the AOT Browser form is a toggle button enabling the ability to view the source code. Enabling this button is only supported in environments that contain source code, such as Development or Demo OneBoxes.

Enabled

Disabled




View Extensions Inline

At the top of the AOT browser form is a toggle button to turn on or off the ability to view the extensions inline in the tree. The setting will be remembered in the user’s usage data once the form is closed.

When enabled, extensions will be shown in the tree where they belong. They are bolded and have the name of the extension they belong to in parenthesis after the name.

Viewing extensions as separate node

When the toggle is disabled, the extensions show up as a separate node at the bottom of the tree.














Search/Filter




Search by object name or label

Search both by the AOT node name





Search by the object label property





Filter by object type


 



Open from Form Personalization

1. Open the form in the web UI that you would like to browse



2. Right click on any element of the form and select form information



3. Click on the form name


4. At the bottom of the dialog click “Open in AOT browser”



5. The AOT browser will open for the form and select the control that was right-clicked in the calling form



Open from Data Entities Form

1. Navigate to System Administration > Workspaces > Data management





3. Select the entity you want to browse and click “Open in AOT browser” at the top



4. The AOT Browser will open and display the data entity




Ref1  arbelatech
Ref2 dynamics-tips.com




Monday, November 21, 2022

D365 F&O - Create custom workflow in Dynamics 365


This guide will explain every step needed to create your custom workflow in Dynamics 365.

Create Enum

The base enum is used to define the status of the workflow. Create a new Enum for the workflow status

We can use VersioningDocumentState Enum from [Application Suite] Model

But in this article, we will create new Enum for our Customized workflow






Create A New Field on the Table

– Here, we use the table SF_Table as an example. Open the table and drag Enum to table.


Create Table Methods  

Next, you will be required to create methods on the table:

You can add method for custom table like below

Create methods with the following names

·        canSubmitToWorkflow

·        UpdateCustWorkflowState


Very Important Note :

For Table Extensions

Extend the table

Create a new class   TableName_Extension

Create methods with the following names

·        canSubmitToWorkflow

·        UpdateCustWorkflowState

 

public boolean canSubmitToWorkflow(str _workflowType = '')

    {

        boolean ret;

 

        ret = super(_workflowType);

        if (this.SF_WorkflowStatus ==  SF_WorkflowStatus::Draft)

        {

            ret = boolean::true;

        }

        else

        {

            ret = boolean::false;

        }

        return ret;

    }

  

static void updateWorkflowStatus(RefRecId _recId, SF_WorkflowStatus _status)

    {

        SF_Table _SF_Table;

 

        select forupdate _SF_Table

           where _SF_Table.RecId == _recId;

        

        ttsBegin;

        _SF_Table.SF_WorkflowStatus = _status;

        _SF_Table.update();

        ttsCommit;

 

    }

 

Create query for the custom table




  Create workflow category


 Set the following properties for the Work flow category

Module – Select the module (in which module workflow category belongs).

Label : set the label


Create work flow type


 Set the following to create the workflow types.

1-     Category – Name of the Created Workflow category.  

2-     Query – Name of the created query.

3-     Document menu item – Name of display menu item for the form to enable Workflow.


Click Finish to create workflow type


Add the following code Work flow type event handler

EventHandler class which gives implementation to handle different workflow events.

 

public class  SF_WorkflowTypeEventHandler implements WorkflowCanceledEventHandler, 

       WorkflowCompletedEventHandler,

       WorkflowStartedEventHandler

{

    public void started(WorkflowEventArgs _workflowEventArgs)

       {

             // TODO:  Write code to execute once the workflow is started.

        SF_Table::updateWorkflowStatus(_workflowEventArgs.parmWorkflowContext().parmRecId(),SF_WorkflowStatus::Submitted);

       }

 

    public void canceled(WorkflowEventArgs _workflowEventArgs)

       {

             // TODO:  Write code to execute once the workflow is canceled.

        SF_Table::updateWorkflowStatus(_workflowEventArgs.parmWorkflowContext().parmRecId(),SF_WorkflowStatus::Canceled);

       }

 

    public void completed(WorkflowEventArgs _workflowEventArgs)

       {

             // TODO:  Write code to execute once the workflow is completed.

        SF_Table::updateWorkflowStatus(_workflowEventArgs.parmWorkflowContext().parmRecId(),SF_WorkflowStatus::Completed);

       }

 

}

 

Enable Workflow on the custom form Design properties

1-     Workflow Enabled – Yes  

2-     WorkflowDatasource – Name of the form data source

3-     Workflow Type – Name of the custom Workflow Type


Add the below logic to submit manager class

 

public class SF_WorkflowTypeSubmitManager

{

    public static void main(Args _args)

       {

             //  TODO:  Write code to execute once a work item is submitted.

 

        SF_Table                           _SF_Table;

        SF_WorkflowTypeSubmitManager     submitManger;

        recId _recId =                      _args.record().RecId;

        WorkflowCorrelationId               _workflowCorrelationId;

        workflowTypeName                    _workflowTypeName = workFlowTypeStr("SF_WorkflowType");

        WorkflowComment                     note = "";

        WorkflowSubmitDialog                workflowSubmitDialog;

        submitManger =                      new SF_WorkflowTypeSubmitManager();

     

        //Opens the submit to workflow dialog.

        workflowSubmitDialog = WorkflowSubmitDialog::construct(_args.caller().getActiveWorkflowConfiguration());

        workflowSubmitDialog.run();

 

        if (workflowSubmitDialog.parmIsClosedOK())

        {

            _SF_Table = _args.record();

            // Get comments from the submit to workflow dialog.

            note = workflowSubmitDialog.parmWorkflowComment();

            try

            {

                ttsbegin;

                _workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName, _SF_Table.RecId, note, NoYes::No);

                _SF_Table.SF_WorkflowStatus = SF_WorkflowStatus::Submitted;

                _SF_Table.update();

                ttscommit;

                // Send an Infolog message.

                info("Submitted to workflow.");

            }

            catch (Exception::Error)

            {

                error("Error on workflow activation.");

            }

        }

        _args.caller().updateWorkFlowControls();

       }

 

}

 

Create a Workflow Approval 

In this step maybe you need to build model first.

Go to Table and create new Table field group





Click Finish



Add the following code to Work flow approval event handler

public final class SF_WorkflowApprovalEventHandler implements WorkflowElementCanceledEventHandler,

       WorkflowElemChangeRequestedEventHandler,

       WorkflowElementCompletedEventHandler,

       WorkflowElementReturnedEventHandler,

       WorkflowElementStartedEventHandler,

       WorkflowElementDeniedEventHandler,

       WorkflowWorkItemsCreatedEventHandler

{

    public void started(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once the workflow is started.

       }

 

    public void canceled(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once the workflow is canceled.

        SF_Table::updateWorkflowStatus(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), SF_WorkflowStatus::Canceled);

       }

 

    public void completed(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once the workflow is completed.

        SF_Table::updateWorkflowStatus(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), SF_WorkflowStatus::InReview);

       }

 

    public void denied(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once the workflow is denied.

        SF_Table::updateWorkflowStatus(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), SF_WorkflowStatus::Rejected);

       }

 

    public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once change is requested for the workflow.

        SF_Table::updateWorkflowStatus(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), SF_WorkflowStatus::ChangeRequest);

       }

 

    public void returned(WorkflowElementEventArgs _workflowElementEventArgs)

       {

             // TODO:  Write code to execute once the workflow is returned.

        SF_Table::updateWorkflowStatus(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), SF_WorkflowStatus::Rejected);

       }

 

    public void created(WorkflowWorkItemsEventArgs _workflowWorkItemsEventArgs)

       {

             // TODO:  Write code to execute once work items are created.

       }

 

}

 

Craet New workflow Emelment Refrence to the supported elements node of the Workflow type created  


Set Element Name and Name (SF_WorkflowApproval)

Set the following properties for the menu item

Set the following properties:

- EnumTypeParameter to ModuleAxapta.

- EnumParameter to “Ledger”.



Add Display menu to Menu and Set Display In content Area to YES



 Design the Workflow.

·        Navigate to General Ledger > Journal Setup > General Ledger workflows.

·        Create a new workflow instance of the workflow type you created

 Very Important Note:

 You must use Microsoft Edge to start workflow definition

 


  • Define the states from Start to End of the workflow.
    • Drag approval element from Toolbox on the left to the Designer pane on the right.



Resolve any errors and warnings by setting workflow and approval element properties.

Activate it.



Go to your form >> Create new record >> Save

Workflow is activated on form