Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Monday, December 13, 2021

Enter data from new line in SSRS and Formula in D365fo

 =Format(Fields!QuotationDate.Value, "MMM-dd yyyy") & Microsoft.VisualBasic.Constants.vbcrlf & Microsoft.VisualBasic.Constants.vbcrlf & Fields!CustomerName.Value & Microsoft.VisualBasic.Constants.vbcrlf & Fields!CustomerAddress.Value



 =Format(Fields!QuotationDate.Value, "MMM-dd yyyy") & vbcrlf & vbcrlf & Fields!CustomerName.Value & vbcrlf & Fields!CustomerAddress.Value


=Fields!PurchOrderDocNum.Value & vbcrlf & Format(Now(),"dd/MM/yyyy")


=IIF(Fields!CompLabelPrice.Value = "0.00",Nothing, Format(Fields!CompLabelPrice.Value, "#,0.00;(#,0.00)")) & " /-"

--------------------------------------------------------------------------------------------------------

To Get user specific date time on report

-

=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "d", Parameters!AX_RenderingCulture.Value) & vbCrLf & Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "t", Parameters!AX_RenderingCulture.Value)

--------------------------------------------------------------------------------------------------------

Print every word with new line

=Replace(Fields!Text2.Value," ", System.Environment.NewLine)

--------------------------------------------------------------------------------------------------------


Print Page number on SSRS in D365 FO

Visual studio expression to print page number on every pages of report


 ="Page "&Globals!PageNumber &" of "&Globals!TotalPages

Saturday, December 11, 2021

Insert User ID in All user group in D365fo

 Assign user id in All user group in D365 FO


insert into USERGROUPLIST ( USERID, GROUPID)

select 'anant.dubey', GROUPID from USERGROUPLIST where GROUPID not in (select GROUPID from USERGROUPLIST where USERID = 'anant.dubey') group by GROUPID


Tuesday, October 12, 2021

Enable delete button on Purchase order or change Purchase order status or delete purchase order versions in d365


To change that status to draft write following code where we will change its status to draft and further code to is to remove version of purchase order which necessary to make delete button enabled on purchase order form


code:-


/// <summary>
/// extension of class: ReqTransPoMarkFirm
/// </summary>
[ExtensionOf(classStr(ReqTransPoMarkFirm))]
final class ReqTransPoMarkFirmCFSClass_Extension
{
    public container conPurchOrders;

    /// <summary>
    /// updatePurchTable
    /// </summary>
    /// <param name = “_purchTable”>_purchTable</param>
    protected void updatePurchTable(PurchTable _purchTable)
    {
        conPurchOrders += _purchTable.PurchId;

        next updatePurchTable(_purchTable);
    }

    /// <summary>
    /// purchTablePostProcessing
    /// </summary>
    protected void purchTablePostProcessing()
    {
        next purchTablePostProcessing();

        for (int i = 1; i <= conLen(conPurchOrders); i++)
        {
            PurchTable purchTable = PurchTable::find(conPeek(conPurchOrders, i), true);

            if(purchTable.RecId)
            {
                ttsbegin;
                //delete the version created for po
                PurchTableVersion purchTableVersion = PurchTableVersion::findLatest(purchTable.PurchId, purchTable.DataAreaId, true);

                if(purchTableVersion.RecId)
                {
                    purchTableVersion.delete();
                }

                purchTable.ChangeRequestRequired = NoYes::No;
                purchTable.DocumentState         = VersioningDocumentState::Draft;
                purchTable.update();

                ttscommit;
            }
        }

    }


Ref: - https://www.cloudfronts.com/change-planned-purchase-order-status-as-draft-insted-of-default-approved/ 

Add link on infolog message in D365 fo

 class CFSMessageAPI

{
    public static void main(Args _args)
    {
        SalesTable            salesTable = SalesTable::find('SH-000121');
        MenuItemMessageAction actionData = new MenuItemMessageAction();

        actionData.MenuItemName(menuItemDisplayStr(SalesTable));
        actionData.TableName(tableStr(SalesTable));
        actionData.RecId(salesTable.RecId);
        str jsonData = FormJsonSerializer::serializeClass(actionData);

        int64 messageId = Message::AddAction(MessageSeverity::Informational, "Sales order details", salesTable.customerName(), MessageActionType::DisplayMenuItem, jsonData);
    }

}
Ref: - https://www.cloudfronts.com/message-api-messageaddaction-in-d365fo-version-10-0-10-pu34-new-feature/

Add FactBox in D365 fo

Ref: - https://www.cloudfronts.com/factbox-of-workflow-history-on-purchase-order-in-d365fo/ 

Details: 

Well, Factbox is a very pretty cool feature available from the earlier version AX 2012. It is very easy to achieve in Dynamics 365 as well. 

Here we will see how easy it is and steps for that. 







 

















As shown in the above image, we will be going to create factbox for the “Tracking details list”

Steps: 

Create the solution in Visual Studio and project for that. We’ll be required four objects mainly that is one display MenuItem, Table, Form (on which to display factbox), another Form (factbox). Reference attached below:

1. Table

For displaying workflow history, we need to create the extension of table WorkflowTrackingStatusTable and create the normal relation and its relevant properties as

2. Factbox

Now we are required to create the factbox of workflow history. For that we will use the effortless technique, where we will duplicate the standard form “WorkflowStatus” and will name as CFSPurchTableWorkflowHistoryFactBox (give name as per your naming convention standards)

After duplicating and renaming the form, we need to change the pattern as “custom”



After applying the custom pattern, delete the NavigationList which is not required in factbox, and do visible false ActionPane and PanelTab

After that create the new Grid and assign the data source to it in the property and put all the required fields to show in factbox

3. Display MenuItem

We will attach the created factbox form to the display menu item and relevant label “Workflow history”

4. Base form

Base form we call it as where we will attach the factbox. Here it is purchase form. Go to Parm section and create a new part and give it a relevant name and its properties

Properties: 

Data source: Attached data source with which workflow history is connected
Data Source Relation: WorkflowTable.RelationName
Name: Part name

That’s it. Build the project and go the frontend and check the output how it looks like.

Conclusion:

It results as (we can scroll left and right to see all the tracking details list)

Hurray, How pretty it looks like!

Synchronize DB using power shell in d365 fo

 

K:\AOSService\webroot\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe 
-bindir "K:\AosService\PackagesLocalDirectory" 
metadatadir "K:\AosService\PackagesLocalDirectory" 
-sqluser "axdbadmin" -sqlserver "." -sqldatabase "AxDB" 
-setupmode "sync" -syncmode "fullall" 
-isazuresql "false" -sqlpwd "AOSWebSite@123" 
-logfilename "H:\MSSQL_LOGS\AxDB_log.log"
Ref: - https://www.cloudfronts.com/d365-finance-and-operations-database-synchronization-using-powershell/