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

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, August 8, 2019

Customizing Filter Capability option on GRID QUICK FILTER in D365 FO

Customizing Filter Capability option  on GRID QUICK FILTER in Dynamics 365 Finance and Operations


Class: GridQuickFilterProvider)
Method: applyFilter

Created new class

/// <summary>
/// The <c>GridQuickFilterProvider</c> provides an interface used to manage the interactions between a <c>QuickFilterControl</c> and the <c>FormGridControl</c> that it filters.
/// </summary>
[ExtensionOf(classStr(GridQuickFilterProvider))]
final class SANGridQuickFilterProvider_Extension
{
    /// <summary>
    /// Apply the specified filter value on the field.- COC
    /// </summary>
    /// <param name = "fieldName">The name of the field to filter.</param>
    /// <param name = "filterValue">The value of the filter.</param>
    public void applyFilter(str fieldName, str filterValue)
    {
        str filterValueCoC;
        filterValueCoC = SysQuery::ValueLike(filterValue);
        info(strFmt("%1-%2",filterValue,filterValueCoC));
        next applyFilter(fieldName, filterValueCoC);
    }

}

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

Tuesday, May 14, 2019

Save file to AZURE blob storage account in D365 FO

using BlobStorage = Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.Dynamics.AX.Framework.FileManagement;
using Microsoft.Azure;
using fileShareStorage = Microsoft.WindowsAzure.Storage.File;
/// <summary>
/// Class Saving File to Azure Storage contianer Blob or file share folder
/// </summary>
class SONFileToAzureStorage
{
    NoYes               IsSuccess;
    public Str          accountName;
    public Str          accountKey;

    /// <summary>
    /// Get /set Operation completion status
    /// </summary>
    /// <param name = "_IsSuccess">setting Operational current status</param>
    /// <returns>operational Status</returns>
    public NoYes parmOperationSuccess(NoYes _IsSuccess = IsSuccess)
    {
        IsSuccess = _IsSuccess;
        return IsSuccess;
    }

    /// <summary>
    /// Get /set Operation completion status
    /// </summary>
    public void initialize()
    {
        accountName = "";// TODO - Need to map
        accountKey = "";// TODO - Need to Map
    }

    /// <summary>
    /// Method will execute code to save file to Azure storage folders based current system setup
    /// </summary>
    /// <param name = "_fileName">Getting file name to process in to Azure storage</param>
    /// <param name = "_fileContent">Get total fiel count to process</param>
    /// <param name = "_containerName">Get specific azure container to process
    /// <param name = "_fileFormat">Get specific file format to process
    /// </param>
    public void saveFileInAzureBlobStorage(str _fileName,str _fileContent,Str  _containerName, Str  _fileFormat)
    {
        System.Exception            ex;
     
        try
        {           
            TextStreamIo            file = TextStreamIo::constructForWrite();
            container               mainContainer; 
            mainContainer = conNull();
            mainContainer = conIns(mainContainer,1,_fileContent);
     
            file.writeExp(mainContainer);

            str filetemppath = File::SendFileToTempStore(file.getStream(),_fileName);
            System.IO.Stream fileStream = File::UseFileFromURL(filetemppath);

            var storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey);
            BlobStorage.CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
            if (storageAccount)
            {
                fileShareStorage.CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
                fileShareStorage.CloudFileShare share = fileClient.GetShareReference(_containerName);

                //Create container in blob if not exists
                // var blobcli = storageAccount.CreateCloudBlobClient();
                //Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer cont = blobcli.GetContainerReference("from-d365")

                if (!share.Exists(null, null))
                {
                    throw error(strFmt("@SSY:AzureFileShareIsMissing",_containerName));
                }

                fileShareStorage.CloudFileDirectory cloudDir = share.GetRootDirectoryReference();
                fileShareStorage.CloudFile fileToSave = cloudDir.GetFileReference(_fileName);

                try
                {
                    fileToSave.UploadFromStreamAsync(fileStream,null,null,null);
                    info(strFmt("@SSY:FilePlacedInAzure",_fileName));
                    this.parmOperationSuccess(NoYes::Yes);
                }
                catch(Exception::Error)
                {
                    ex = CLRInterop::getLastException();
                    error(ex.ToString());
                    //info("@SSY:ErrorWhileUploadingFileInAzureBlobStoarge");
                }
                Catch(Exception::Warning)
                {
                    ex = CLRInterop::getLastException();
                    warning(ex.ToString());
                }
                Catch(Exception::CLRError)
                {
                    ex = CLRInterop::getLastException();
                    checkFailed(ex.ToString());
                }
         
            }
            else
            {
                info("@SSY:ErrorInAzureStorageAccount");
            }
        }
        catch(Exception::Error)
        {
            ex = CLRInterop::getLastException();
            error(ex.ToString());
            //info("@SSY:ErrorWhileUploadingFileInAzureBlobStoarge");
        }
        Catch(Exception::Warning)
        {
            ex = CLRInterop::getLastException();
            warning(ex.ToString());
        }
        Catch(Exception::CLRError)
        {
            ex = CLRInterop::getLastException();
            checkFailed(ex.ToString());
        }

    }

    public static SONFileToAzureStorage construct()
    {
        return new SONFileToAzureStorage();
    }

}


//Test
Static void Man(Args  _args)
{
//TODO. Map Account Name and Account key
SONFileToAzureStorage azureStorage;
azureStorage = new SONFileToAzureStorage();
azureStorage.Intialize();
azureStorage.saveFileInAzureBlobStorage("Test.txt","Blob file content","TestCon",".txt");
if(azureStorage.parmOperationSuccess())
{
//File placed in to specified folder
}
}

Wednesday, April 3, 2019

Explore metadata search feature in Visual Studio D365 FO


Access the Metadata search tool window from the Dynamics 365 > Metadata Search.


Search Keyword Description
Code # Search for a specific code. Use quotes around code snippets. The matching source code is the elements that contain the specified code snippet.
Type # Filter the elements by type  Each comma-separated value should be the name of an element or sub-element type (root type or subtype) (i.e. table, class, field). Logic of filtering is:
Model # Filter the elements by model Each comma-separated value should be the name of a model in your application
Name # Filter the elements by name This is the default filter, meaning if you just type a filter value, it is assumed to be an element name. Each comma-separated value is an acceptable element name.
Property # Search for element with the property with the specific value  Each comma-separated value should be in the form property_name=property_value



Note: Make sure there should not be any space in between Type values otherwise it will show "Invalid query" error.

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.

Skip Inventory reservation on Sales order lines in D365FO

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