Deep links available in every form

Ievgen Miroshnikov gave me the idea and Microsoft also has some information here.

The following extends the standard button available in every Dynamics 365 for Finance and Operations form to provide the deep link to the currently select record of the primary form data source.

Copy the link and share it. The recipient will jump directly to the currently selected record.

(I wonder why Microsoft doesn’t provide this in standard D365FO – this is actually what you would expect from the button.)

Snap079660

using Microsoft.Dynamics.AX.Framework.Utilities;
using Microsoft.Dynamics.@Client.ServerForm.Contexts;

/// <summary>
/// The class <c>URLUtility_Extension</c> contains extension methods for the <c>URLUtility</c> class.
/// </summary>
[ExtensionOf(classStr(URLUtility))]
public static class URLUtility_Extension
{
    public static str generateRecordUrl(str _menuItemName, MenuItemType _menuItemType, DataSourceName _dataSourceName, Map _indexFieldValuesMap, DataAreaId _dataAreaId = curExt())
    {
        System.Uri host                     = SessionContext::Get_Current().Get_RequestUrl();
        UrlHelper.UrlGenerator generator    = new UrlHelper.UrlGenerator();
        generator.MenuItemName              = _menuItemName;
        generator.MenuItemType              = _menuItemType;
        generator.HostUrl                   = host.GetLeftPart(System.UriPartial::Path);
        generator.Company                   = _dataAreaId;
        generator.EncryptRequestQuery       = true;

        if (_dataSourceName && _indexFieldValuesMap)
        {
            MapEnumerator mapEnumerator = _indexFieldValuesMap.getEnumerator();

            var requestQueryParameterCollection = generator.RequestQueryParameterCollection;

            while (mapEnumerator.moveNext())
            {
                requestQueryParameterCollection.UpdateOrAddEntry(_dataSourceName, mapEnumerator.currentKey(), mapEnumerator.currentValue());
            }
        }

        return generator.GenerateFullUrl().AbsoluteUri;
    }

    public static str generateRecordUrlFromDataSource(FormDataSource _formDataSource)
    {
        FormRun         formRun         = _formDataSource.formRun();
        str             menuItemName    = formRun.args().menuItemName();
        MenuItemType    menuItemType    = formRun.args().menuItemType();
        DataSourceName  dataSourceName  = _formDataSource.name();

        TableId   tableId   = _formDataSource.table();
        DictTable dictTable = new DictTable(tableId);
        DictIndex dictIndex = new DictIndex(tableId, dictTable.primaryIndex());

        int     fieldCount          = dictIndex.numberOfFields();
        Map     indexFieldValuesMap = new Map(Types::String, Types::String);
        Common  record              = _formDataSource.cursor();
        FieldId primaryKeyFieldId;

        for (int fieldIndex = 1; fieldIndex <= fieldCount; fieldIndex++)
        {
            primaryKeyFieldId = dictIndex.field(fieldIndex);

            indexFieldValuesMap.insert(fieldId2Name(tableId, primaryKeyFieldId), any2Str(record.(primaryKeyFieldId)));
        }

        return URLUtility::generateRecordUrl(menuItemName, menuItemType, dataSourceName, indexFieldValuesMap, record.DataAreaId);
    }

    public static str generateUrl(FormRun formRun)
    {
        str url = next generateUrl(formRun);

        if (formRun && formRun.dataSource(1) && formRun.dataSource(1).cursor())
        {
            url = URLUtility::generateRecordUrlFromDataSource(formRun.dataSource(1));
        }
        return url;
    }
}
Advertisements

Change based alerts using Microsoft Flow

Rob showed how to make Date Based Alerts using Microsoft Flow. So this is a great start into the future of the still missing AX alerts. But of course we want change based alerts for example to be informed about a sales order that has been processed. It does not take to long to find out that this is still not possible in the way it has been in the past. However you can get a message once the sales order reaches a certain status:

You see that the sales order is hard coded and once the sales order status has changed, you will receive an email every day. So why not use your Android Flow App to disable or delete the Flow?

Mass changes to Number Sequences in Dynamics 365 for Operations

Get Microsoft Dynamics Office Add-in for Excel 2016

https://store.office.com/en-001/app.aspx?assetid=WA104379629&ui=en-US&rs=en-001&ad=US&appredirect=false

Open Number sequences in Excel

In D365fO go to Organization administration > Number sequences > Number sequences

Press Office Button > Open in Excel

Add format field to Excel

In Excel add the Format field. (Note: add the Name Field as well! Otherwise it will be reset.)


Edit data

Change the format as desired (e.g. remove the dash using excel search & replace)

Publish

Press Publish

Advanced Filter/Sort in D365 1611 (November 2016)

Szenario

  • I want to filter the released products by “Tracking dimension group”
  • In AX 2012 R3 I right-clicked on the field I wanted to search by, selected “Filter by field” and added entered the search-text.

Steps in D365

What doesn’t work

  • A right mouse click doesn’t allow me to filter.
  • The filter tab doesn’t allow me to filter by “Tracking dimension group”

Use “Advanced Filter/Sort”

  • This does not differ from AX 2012, but the shortcut of AX 2012 is sorely missed
  • Open “Advanced Filter/Sort”

  • Add Tables

  • Add filter field

  • Hey presto!