Showing posts with label Retail AX. Show all posts
Showing posts with label Retail AX. Show all posts

Monday, January 30, 2023

Spliting Online store transaction in D365FO X++

//Online store transaction - Retail synchronize order

[ExtensionOf(classStr(RetailSyncOrdersSchedulerTask))]

final class RetailSyncOrdersSchedulerTaskCls_POL_Extension

{

    public void run()

    {

        Array             listOfCurTransactions, listOfTransactionsPostOrderSplit;


        listOfTransactionsPostOrderSplit= new Array(Types::Int64);

         listOfCurTransactions = Array::create(this.parmPackedTransactionRecIdList());


        listOfTransactionsPostOrderSplit= SANOrderSplit::splitOrders( listOfCurTransactions);

        this.parmPackedTransactionRecIdList(listOfTransactionsPostOrderSplit.pack());


        next run();

    }


}

Friday, September 9, 2022

Online store transaction new field flow to Sales order in D365FO

Set extension property for commerce order 

using Microsoft.Dynamics.Commerce.Runtime.Services.CustomerOrder;

using Microsoft.Dynamics.Commerce.Runtime.DataModel;

/// <summary>

/// Extension of <b>RetailTransactionTransformer</b> class

/// </summary>

[ExtensionOf(classStr(RetailTransactionTransformer))]

final class RetailTransactionTransformerCls_POL_Extension

{

/// <summary>

    /// Convert retail sales transaction into <b>ItemInfo</b> object

    /// </summary>

    public static ItemInfo ReadOneTransactionSalesTrans(RetailTransactionTable transactionTable, RetailTransactionSalesTrans salesTrans)

    {

        ItemInfo itemInfo = next ReadOneTransactionSalesTrans(transactionTable, salesTrans);

        ExtensionPropertyCollection extensionPropertyCollection = itemInfo.ExtensionProperties;

        CommerceProperty splitPropery = new Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty(fieldStr(RetailTransactionSalesTrans, <CustomField>), enum2int(salesTrans.<CustomField>));

        CommerceProperty comment            = new Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty(fieldStr(RetailTransactionSalesTrans, comment), salesTrans.comment);

        extensionPropertyCollection.Add(splitPropery );

        extensionPropertyCollection.Add(comment);

        return itemInfo;

    }


    /// <summary>

    /// This method is used to read sales transactions for return.

    /// </summary>

    public static ItemInfo ReadOneTransactionSalesTransForReturn(

                RetailTransactionTable transactionTable,

                RetailTransactionSalesTrans salesTrans)

    {

        ItemInfo itemInfo = next ReadOneTransactionSalesTransForReturn(transactionTable, salesTrans);


        ExtensionPropertyCollection extensionPropertyCollection = itemInfo.ExtensionProperties;


        CommerceProperty customLineNumber   = new Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty(fieldStr(RetailTransactionSalesTrans, customPortalLineNum), salesTrans.customPortalLineNum);        

        extensionPropertyCollection.Add(customLineNumber   );

        return itemInfo;

    }


    /// <summary>

    /// Convert a transaction data into customer order info.

    /// </summary>

    public static CustomerOrderInfo ConvertTransactionToCustomerOrderInfo(RetailTransactionTable transactionTable)

    {

        CustomerOrderInfo customerOrderInfo =  next ConvertTransactionToCustomerOrderInfo(transactionTable);

        var extensionPropertyCollection = customerOrderInfo.ExtensionProperties;

        CommerceProperty custPurchaseOrder  = new Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty(fieldStr(RetailTransactionTable, CustPurchaseOrder), transactionTable.CustPurchaseOrder);

        CommerceProperty  isImport= new Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty(fieldStr(RetailTransactionTable, isImport), enum2Str(transactionTable.isImport));        

        extensionPropertyCollection.Add(custPurchaseOrder);

        extensionPropertyCollection.Add(isImport);

        return customerOrderInfo;

    }

}


using Microsoft.Dynamics.Commerce.Runtime.Services.CustomerOrder;

/// <summary>

    /// To update sales order while creating through sync orders from retail

    /// </summary>

    [SubscribesTo(classStr(RetailTransactionServiceOrders), staticDelegateStr(RetailTransactionServiceOrders, beforeCreatingRetailOrderLines))]

    public static void RetailTransactionServiceOrders_beforeCreatingRetailOrderLines(SalesTable _salesTable, Microsoft.Dynamics.Commerce.Runtime.Services.CustomerOrder.CustomerOrderInfo _customerOrderInfo)

    {

        var extensionPropertyCollection = _customerOrderInfo.ExtensionProperties;

        Microsoft.Dynamics.Commerce.Runtime.DataModel.CommercePropertyValue propertyValue;

        boolean                 update = false;

        for (int i=0; i < extensionPropertyCollection.get_Count(); i++)

        {

            var commerceProperty = extensionPropertyCollection.get_Item(i) as Microsoft.Dynamics.Commerce.Runtime.DataModel.CommerceProperty;

            switch(commerceProperty.Key)

            {

                case fieldStr(RetailTransactionTable, custPurchaseOrder):

                     propertyValue = commerceProperty.Value;

                    _salesTable.PurchOrderFormNum = propertyValue.StringValue;

                    update = true;

                    break;

                case fieldStr(RetailTransactionTable, <CustomField>): //Enum

                    propertyValue = commerceProperty.Value;

                    NoYesId noYesId;

                    _salesTable.<CustomField> = str2Enum(noYesId,propertyValue.StringValue);

                    update = true;

                    break;

                case fieldStr(RetailTransactionTable, <CustomField>):

                    propertyValue = commerceProperty.Value;

                     _salesTable.<CustomField>= propertyValue.StringValue;

                    break;

            }

             

        }

        if(update)

        {

            _salesTable.doUpdate();

        }

    }

Thursday, March 17, 2022

ODATA Request URL D365FO - Testing postman

 POST:

https://<D365FOURL>/data/<EntityPublicCollectionName>

Body:

{
    "dataAreaId": "USMF",
    "InvoiceId": "USMF00000040",
    "InvoiceAmount": 13110.540000,
    "Status": "Sent"
}

PATCH:
https://<D365FOURL>/data/<EntityPublicCollectionName>(dataAreaId='USMF',InvoiceId='USMF00000040')?cross-company=true

Body:
{
    "Status": "Paid"
}

Thursday, February 10, 2022

New operators are added in X++ D365FO

 These are new two operators added to X++ libraries.

 *= 

 /=

Example:

X *= 2
X /= 2

These are short for X = X * 2 and X = X / 2.

Friday, May 24, 2019

Timezone and TZId field in Dynamics

Timezone descriptionTimeZoneTZId
(GMT-12:00) International Date Line West2424001
(GMT-11:00) Midway Island, Samoa6565001
(GMT-10:00) Hawaii3939001
(GMT-09:00) Alaska22001
(GMT-08:00) Pacific Time (US &amp; Canada)5858001
(GMT-08:00) Tijuana, Baja California5959001
(GMT-07:00) Arizona7575001
(GMT-07:00) Mountain Time (US &amp; Canada)4747001
(GMT-07:00) Chihuahua, La Paz, Mazatlan4848001
(GMT-06:00) Central America1515001
(GMT-06:00) Central Time (US &amp; Canada)2121001
(GMT-06:00) Guadalajara, Mexico City, Monterrey2222001
(GMT-06:00) Saskatchewan1111001
(GMT-05:00) Bogota, Lima, Quito, Rio Branco6363001
(GMT-05:00) Eastern Time (US &amp; Canada)2929001
(GMT-05:00) Indiana (East)7474001
(GMT-04:00) Atlantic Time (Canada)66001
(GMT-04:00) La Paz6464001
(GMT-04:00) Manaus1717001
(GMT-04:00) Santiago5757001
(GMT-04:30) Caracas8585001
(GMT-03:30) Newfoundland5454001
(GMT-03:00) Brasilia2828001
(GMT-03:00) Buenos Aires, Georgetown6262001
(GMT-03:00) Greenland3636001
(GMT-03:00) Montevideo8383001
(GMT-02:00) Mid-Atlantic4545001
(GMT-01:00) Azores1010001
(GMT-01:00) Cape Verde Is.1212001
(GMT) Casablanca, Monrovia, Reykjavik3737001
(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, Londo3535001
(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna7979001
(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Pragu1818001
(GMT+01:00) Brussels, Copenhagen, Madrid, Paris6060001
(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb1919001
(GMT+01:00) West Central Africa7878001
(GMT+02:00) Amman4343001
(GMT+02:00) Athens, Bucharest, Istanbul3838001
(GMT+02:00) Beirut4646001
(GMT+02:00) Minsk2727001
(GMT+02:00) Cairo3030001
(GMT+02:00) Harare, Pretoria6868001
(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius3333001
(GMT+02:00) Jerusalem4242001
(GMT+02:00) Windhoek5151001
(GMT+03:00) Baghdad55001
(GMT+03:00) Kuwait, Riyadh33001
(GMT+03:00) Moscow, St. Petersburg, Volgograd6161001
(GMT+03:00) Nairobi2525001
(GMT+03:00) Tbilisi3434001
(GMT+03:30) Tehran4141001
(GMT+04:00) Abu Dhabi, Muscat44001
(GMT+04:00) Baku99001
(GMT+04:00) Caucasus Standard Time8484001
(GMT+04:00) Yerevan1313001
(GMT+04:30) Kabul11001
(GMT+05:00) Ekaterinburg3131001
(GMT+05:00) Islamabad, Karachi, Tashkent8080001
(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi4040001
(GMT+05:30) Sri Jayawardenepura6969001
(GMT+05:45) Kathmandu5252001
(GMT+06:00) Almaty, Novosibirsk5050001
(GMT+06:00) Astana, Dhaka1616001
(GMT+06:30) Yangon (Rangoon)4949001
(GMT+07:00) Bangkok, Hanoi, Jakarta6666001
(GMT+07:00) Krasnoyarsk5656001
(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi2323001
(GMT+08:00) Irkutsk, Ulaan Bataar5555001
(GMT+08:00) Kuala Lumpur, Singapore6767001
(GMT+08:00) Perth7777001
(GMT+08:00) Taipei7070001
(GMT+09:00) Osaka, Sapporo, Tokyo7272001
(GMT+09:00) Seoul4444001
(GMT+09:00) Yakutsk8282001
(GMT+09:30) Adelaide1414001
(GMT+09:30) Darwin77001
(GMT+10:00) Brisbane2626001
(GMT+10:00) Canberra, Melbourne, Sydney88001
(GMT+10:00) Guam, Port Moresby8181001
(GMT+10:00) Hobart7171001
(GMT+10:00) Vladivostok7676001
(GMT+11:00) Magadan, Solomon Is., New Caledonia2020001
(GMT+12:00) Auckland, Wellington5353001
(GMT+12:00) Fiji, Kamchatka, Marshall Is.3232001
(GMT+13:00) Nuku’alofa7373001

Friday, December 21, 2018

Retail SETUP CPOS - Dynamics 365


Retail configuration

For Dynamics 365 for Operations, Version 1611
1.    Run the RetailTenantUpdateTool.
·         The icon for this tool is available on the desktop.
·         This tool is also available at the following location: C:\windowsSystem32WindowsPowerShellv1.0PowerShell.exe -File C:\RetailSDKToolsRetailTenantUpdateTool.ps1
2.    Double-click the icon to start this tool. You will be prompted for your Azure AD credentials. You must use the same credentials that you used in the admin user provisioning tool earlier.

For Dynamics 365 for Operations 7.0
3.    Query Azure AD for your tenant and user ID. Open a Windows PowerShell Integrated Scripting Environment (ISE) window with administrative privileges, and run the following command. You will be prompted for Azure AD credentials. Use the same user account that you used in the admin user provisioning tool earlier.
$msocred = Get-Credential
Connect-MsolService -Credential $msocred
$company = Get-MsolCompanyInformation
Write-Host "TenantID: $($company.ObjectId)"
$msocred.UserName
$users = Get-MsolUser -SearchString "$($msocred.username)"
foreach($u in $users)
{
    if($u.SignInName -eq $msocred.UserName)
    {
       Write-Host "SignInName:$($u.SignInName) UserId: $($u.ObjectId)"
    }
}
4.    Update the following SQL script, and run it in on AXDB for that environment. Supply values for the following parameters from the preceding Windows PowerShell script output:
·         TenantID 
·         UserId 
DECLARE @TenantId NVARCHAR(1024)         DECLARE @UserId NVARCHAR(1024)
SET @TenantId = ‘‘
SET @UserId = ‘‘
IF(LEN(@TenantId) > 0 AND LEN(@UserId) > 0)
    BEGIN
    UPDATE AxDBRAIN.dbo.SYSSERVICECONFIGURATIONSETTING SET [VALUE] = @TenantId WHERE [NAME] = ‘TENANTID’
    UPDATE RetailHoustonStore.ax.SYSSERVICECONFIGURATIONSETTING SET [VALUE] = @TenantId WHERE [NAME] = ‘TENANTID’
    UPDATE AxDBRAIN.dbo.RETAILSTAFFTABLE SET EXTERNALIDENTITYID = @TenantId, EXTERNALIDENTITYSUBID = @UserId WHERE STAFFID = ‘000160’
    END
ELSE
    BEGIN
    RAISERROR (15600, -1, -1, ‘TenantId and UserId must be set before running this script’)
    END
5.    Reset Internet Information Services (IIS) by running IISRESET in an elevated Command Prompt window.
6.    Update the Real-time service profile to use the new admin user.
 .      Click Retail > Headquarters setup > Retail scheduler > Real-time service profiles.
a.    Click Retail > Headquarters setup > Retail scheduler > Real-time service profiles.
b.    Edit the JBB record so that it uses the user that you used earlier (for example, **administrator@contosoax7.onmicrosoft.com**).
c.     Run CDX Job 1070 (Staff) for the default channel database.
d.    Verify that the job succeeded by viewing the Download Sessions page on the client.

Prerequisite setup for CPOS

Steps:
1. Navigate to All worker à Select worker à Retail Tab à External Identity à Create new identity
2. Enter external Identity on Retail Tab of Worker detail form
Ex: Alias – <User Id> , UPN - <email Id>, External Sub Identifier - <Telementry Id>

3.    Navigate RetailàChannel Setup àPOS Setup à Registers à select Register and Click à configuration status (To Setup)

Right Corner à Click Approve All

4.    Navigate RetailàChannel Setup àPOS Setup à Devices

Select à Application type à Retail Cloud POS
Click à Validate device for activation
5.    Retail à Retail IT à Distribution Schedule àSelect Job - P-0001 à Click Run Now (In Order to get all default data for POS)

Activate a Modern POS or Cloud POS device by using guided activation

1.    Open the initial device activation page for Modern POS or Cloud POS. You're prompted to sign in.
2.    On the Before you start page, follow the instructions, and then click Next.

3.    Start Cloud POS or Modern POS.
4.    Use your AAD credentials to sign in. The AAD account must already be mapped. For instructions, see Retail Modern POS self-service and device activation. For Cloud POS, the server URL is automatically entered in the address bar. For Modern POS, you must copy and paste the server URL.

5.    Click Next to populate the list of stores.
6.    Select the correct store in the list.

7.    Select the correct register and device. Note: The device can be Pending, De-activated, or Activated. Alternatively, if you turned on the Retail HQ Allow devices to be associated to registers from store setting, you might see a list of registers that have no device associated with them.

8.    Click Activate. The device should be activated.

 Create a device ID from Modern POS and Cloud POS

We have added features to create a device (that is, automatically generate a device ID) from Modern POS or Cloud POS, so that the device can be associated with a register that doesn't yet have devices mapped to it. This functionality can be used in Modern POS only if you set the HQ settings as follows.
1.     Go to Retail > Headquarters setup > Parameters > Retail shared parameters> General.
2.     Under Devices, set Allow register association from device to Yes.
3.     In the Modern POS client, you can now add a device when you select a register that is listed as No associated devices in the guided activation flow.
4.     After you select the register, you can either select a device that doesn't have register mapping or use the Or, Add a Device link.
5.     Click the Or, Add a Device link, and then either enter the new device ID or select automatically create a new device ID for me.
6.     Click Activate to create a new device ID, associate it with the selected register, and complete the activation.

Friday, August 10, 2018

METADATA Objects convert to XML file in AX 2012

Reference: Microsoft Demo data tool

static void MetadataXMLGenrator(Args _args)
{
    Dictionary      dictionary;
    Counter         tableCounter;
    SysDictTable    table;
    Counter         fieldCounter;
    SysDictField    field;
    str             result;

    boolean         isRecID;
    boolean         isTableID;
    boolean         isDatatypeID;
    boolean         isClassID;
    boolean         isFieldID;
    boolean         IsIndexID;
    boolean         isConfigurationKeyId;
    boolean         isEnumId;
    boolean         isLicenseCodeId;
    boolean         isperspectiveId;
    boolean         issecurityKeyId;


    SysModelElement modelElement;
    str             elementType;
    str             tmpfolderpath;
    str             relatedtTableName;

    void write(str _directory, str _name, str _text)
    {
        str path;
        ;

        _text = System.Text.RegularExpressions.Regex::Replace(_text, '\n', '\r\n');
        if (!System.IO.Directory::Exists(_directory))
        {
            System.IO.Directory::CreateDirectory(_directory);
        }
        path = System.IO.Path::Combine(_directory, _name);
        System.IO.File::WriteAllText(path, _text, System.Text.Encoding::get_UTF8());
    }

    boolean isExcluded(SysDictTable _table)
    {
        ;

        return
           _table.isView()
        || _table.isMap()
        || _table.isTmp()
        || _table.isTempDb();
    }

    guid tableOrigin(SysDictTable _table)
    {
        ;
        modelElement = null;
        select firstOnly * from modelElement where modelElement.AxId == _table.id() && modelElement.ElementType == 44;
        if (modelElement)
        {
            return modelElement.Origin;
        }

        return emptyGuid();
    }

    str fmt(guid value, int64 id)
    {
        str digits;
        str o = strReplace(strReplace(guid2str(value), '{', ''), '}', '');

        if (o != '00000000-0000-0000-0000-000000000000')
        {
            return o;
        }

        digits = int642str(id);
        return subStr(o, 0, strLen(o) - strLen(digits)) + digits;
    }

    dictionary = new Dictionary();

    result += '<tables>\n';

    for (tableCounter = 1; tableCounter <= dictionary.tableCnt(); ++tableCounter)
    {
        table = new SysDictTable(Dictionary.tableCnt2Id(tableCounter));

        if (!isExcluded(table))
        {
            result += strFmt('\t<table axid="%1" origin="%2" name="%3" sqlname="%4" %5>\n', table.id(), fmt(tableOrigin(table), table.id()), table.name(), table.name(DbBackend::Sql), table.supportInheritance() ? 'supportsinheritance="true" ' :  '' );

            for (fieldCounter = 1; fieldCounter <= table.fieldCnt(); ++fieldCounter)
            {
                relatedtTableName = '';
                field = new SysDictField(table.id(), table.fieldCnt2Id(fieldCounter));

                if (field.isSql())
                {
                    isRecID = field.isDerivedFrom(extendedTypeNum(RecId));
                    isTableID = field.isDerivedFrom(extendedTypeNum(RefTableId)) || field.isDerivedFrom(extendedTypeNum(RelationType)) || (field.name() == 'InstanceRelationType' && table.supportInheritance() && table.extends() == 0);
                    isDatatypeID = field.isDerivedFrom(extendedTypeNum(ExtendedTypeId));
                    isClassID = field.isDerivedFrom(extendedTypeNum(ClassId));
                    isFieldID = field.isDerivedFrom(extendedTypeNum(FieldId));
                    IsIndexID = field.isDerivedFrom(extendedTypeNum(IndexId));
                    isConfigurationKeyId = field.isDerivedFrom(extendedTypeNum(ConfigurationKeyId));
                    isEnumId = field.isDerivedFrom(extendedTypeNum(EnumId));
                    isLicenseCodeId = field.isDerivedFrom(extendedTypeNum(LicenseCodeId));
                    isperspectiveId = field.isDerivedFrom(extendedTypeNum(PerspectiveId));
                    issecurityKeyId = field.isDerivedFrom(extendedTypeNum(SecurityKeyId));

                    if (isTableID)
                    {
                        elementType = "Table";
                    }
                    else if (isClassID)
                    {
                        elementType = "Class";
                    }
                    else if (isDataTypeID)
                    {
                        elementType = "DataType";
                    }
                    else if (isFieldID)
                    {
                        elementType = "Field";
                        relatedtTableName = field.relatedTableName();
                    }
                    else if (IsIndexID)
                    {
                        elementType = "Index";
                        relatedtTableName = field.relatedTableName();
                    }
                    else if(isConfigurationKeyId)
                    {
                        elementType = "ConfigurationKey";
                    }
                    else if(isEnumId)
                    {
                        elementType = "Enum";
                    }
                    else if(isLicenseCodeId)
                    {
                        elementType = "LicenseCode";
                    }
                    else if(issecurityKeyId)
                    {
                        elementType = "SecurityKey";
                    }
                    else if(isperspectiveId)
                    {
                        elementType = "Perspective";
                    }
                    else
                    {
                        elementType = '';
                    }

                    result += strFmt('\t\t<field axid="%1" origin="%2" name="%3" sqlname="%4" type="%5" %6%7/>\n',
                        field.id(), fmt(field.origin(), field.id()), field.name(), field.name(DbBackend::Sql), field.typeName(),
                        elementType != '' ? ((elementType == ('Field') || elementType == ('Index'))?'elementType="' + elementType + '" '+'relatedTable="'+relatedtTableName + '" ' :'elementType="' + elementType + '" ') : '',
                        isRecID ? 'recid="true" ' : ''
                        );
                }
            }

            result += '\t</table>\n';
        }
    }

    result += '</tables>\n';
    tmpfolderpath = System.Environment::GetEnvironmentVariable('TEMP');
    write(tmpfolderpath, 'Metadata.xml', result);

    info(strFmt("Metadata xml file is created and here is the full path to the file %1\\Metadata.xml",tmpfolderpath));
}

Tuesday, October 31, 2017

Get Organisation hierarchies through X++/SQL

In AX 2012

//Project XPO Download link

Organisation Hierarchies

XPO Project Contains,

1) Query - OrganisationHierarchies
2) View - OrganisationHierarchies
3) Job - GetOrgansationalHierarchy

static void  GetOrgansationalHierarchy(Args _args)
{
    //Reference Query : OMHierarchy
    OMHierarchyType OMHierarchyType1;
    OMHierarchyRelationship OMHierarchyRelationship1;
    OMRevisionEdit OMRevisionEdit1; //check this too
    OMInternalOrganization  omInternalOrganizationP,omInternalOrganizationC;
    OMOperatingUnit  omOperatingUntInt;
 
    //Function to Clear
    void clearBuffer()
    {
        OMHierarchyType1.clear();
        omInternalOrganizationP.clear();
        omInternalOrganizationC.clear();
        omOperatingUntInt.clear();
        OMRevisionEdit1.clear();
        OMHierarchyRelationship1.clear();
    }
    ;
    clearBuffer();
    while select Name,RecId
                from OMHierarchyType1
    {
        while select HierarchyType,ParentOrganization,ChildOrganization
                from  OMHierarchyRelationship1
            where OMHierarchyRelationship1.HierarchyType == OMHierarchyType1.RecId
                    && OMHierarchyRelationship1.ParentOrganization != 0
               outer join  omInternalOrganizationP //Parent Organization
                     where omInternalOrganizationP.RecId == OMHierarchyRelationship1.ParentOrganization
                outer join omInternalOrganizationC //Child Organization
                    where omInternalOrganizationC.RecId == OMHierarchyRelationship1.ChildOrganization
                outer join omOperatingUntInt // Operating unit Type
                    where omOperatingUntInt.PartyNumber == omInternalOrganizationC.PartyNumber
                 
        {
            info(strFmt("Org,%1,%2,%3,%4",OMHierarchyType1.Name,
                                   omInternalOrganizationP.Name,
                                   omInternalOrganizationC.Name,
                                   omOperatingUntInt.OMOperatingUnitType
                                   ));
        }
    }
}


In SQL

SQL Script Query

CREATE VIEW vORGANISATIONHIERARCHIES
AS
SELECT
T1.NAME AS HIERARCHYNAME,
T2.CHILDORGANIZATION AS CHILDORGANIZATION,
T2.PARENTORGANIZATION AS PARENTORGANIZATION,
T2.HIERARCHYTYPE AS HIERARCHYTYPE,
T3.NAME AS PARENT,
T4.NAME AS CHILD,
T5.OMOPERATINGUNITTYPE AS ChildOMOPERATINGUNITTYPE,
T5.OMOPERATINGUNITNUMBER AS ChildOMOPERATINGUNITNUMBER,
T6.OMOPERATINGUNITNUMBER AS ParentOMOPERATINGUNITNUMBER,
T6.OMOPERATINGUNITTYPE AS ParentOMOPERATINGUNITTYPE
FROM OMHIERARCHYTYPE T1
CROSS JOIN OMHIERARCHYRELATIONSHIP T2
LEFT OUTER JOIN DIRPARTYTABLE T3
ON (T2.PARENTORGANIZATION=T3.RECID)
LEFT OUTER JOIN DIRPARTYTABLE T4
ON (T2.CHILDORGANIZATION=T4.RECID)
LEFT OUTER JOIN DIRPARTYTABLE T5
ON ((T4.RECID=T5.RECID)
AND (T5.INSTANCERELATIONTYPE IN (2377) ))
LEFT OUTER JOIN DIRPARTYTABLE T6
ON ((T3.RECID=T6.RECID)
AND (T6.INSTANCERELATIONTYPE IN (2377) ))
 WHERE ( NOT ((T2.PARENTORGANIZATION=0))
AND (T1.RECID=T2.HIERARCHYTYPE))

Thursday, October 5, 2017

Get Current User running report list in Ax 2012 from SQL DB

--Query

SELECT UserInfo.[Name],
ElementName AS [Report Name],
UserInfo.[Enable] AS [Active Employee]
INTO #temp
FROM SysLastValue WITH(NOLOCK)
INNER JOIN UserInfo WITH(NOLOCK)
                ON UserInfo.ID = SysLastValue.UserID
WHERE UserID NOT IN ('Admin', '')
     AND RecordType = 18 /* Report */



SELECT t.[Report Name],
(SELECT COUNT(DISTINCT [Name])
   FROM #temp sub
WHERE sub.[Active Employee] = 1
AND sub.[End User] = 1
AND sub.[Report Name] = t.[Report Name]) AS [# of Active Employees Who Ran The Report]
FROM #temp t
GROUP BY t.[Report Name]
ORDER BY t.[Report Name]

DROP TABLE #temp

Skip Inventory reservation on Sales order lines in D365FO

[ExtensionOf(classStr(InventUpd_Reservation))] final class InventUpd_ReservationCls_SAN_Extension {     void updateNow()     {         if(mo...