Noted: OneBox - Sandbox / Dev-tier 1- Dev-tier 2 From anh An.Bui
Noted: OneBox - Sandbox / Dev-tier 1- Dev-tier 2
Dynamic Retail 365

Song Nghia - Technical Consultant

Onebox và Sandbox là 1 , ám chỉ cái máy đó cài tất cả trong một.
Nếu đó là máy đặt trên Cloud thì Microsoft tạo ra những URL cho D365 và Retail server, để bên ngoài Client gọi vào
còn máy đó đặt dưới On-Premise, thì chỉ chạy được AX trong lòng cái máy đó thôi, và đường dẫn fix cứng luôn

Dev Tier 1: là máy concept one box, và đặt trên Cloud, khi deploy code lên Tier 1 có thể copy - paste, hoặc thông qua LCS
Dev Tier 2: là multi các VM đặt trên Cloud, mỗi VM mỗi role khác nhau, như VM chạy AOS, VM chạy Retail Server và Cloud POS, VM Chạy SQL riêng, khi deploy code lên Tier 2 phải thông qua LCS
Định nghĩa nôm nay vậy cho dễ hiểu: nơi nào mạng yếu, mạng rớt thì nơi đó có RSSU (Retail Store Scale Unit) hiểu nôm na là rinh luôn Retail Server xuống Cửa hàng nằm, máy POS sẽ dùng phần mềm MPOS hoặc Cloud POS để kết nối vào Retail Server trong cửa hàng, còn nếu xui nữa là máy POS bị chuột cắn dây mạng, cách ly với thế giới 14 ngày, thì máy POS phải xài phần mềm MPOS với chế độ Offline để sống qua ngày, đợi thợ tới sửa dây mạng xong rồi sẽ Online lại

Solution:  from my Technical Architect  in company.
Print new custom receipt in end transaction
Print new custom receipt in end transaction
Song Nghia - Technical Consultant

Step 1. Add extension in PostEndTransactionTrigger and return CustomReceipt6.

return this.context.runtime.executeAsync(new Device_1.GetHardwareProfileClientRequest())

.then(function (response) {

var hardwareProfile = response.data.result;

var salesOrderId = options.receipts[0].TransactionId;

var receiptRetrievalCriteria = {

 IsCopy: false,

 IsRemoteTransaction: false,

 IsPreview: false,

 QueryBySalesId: true,

 ReceiptTypeValue: Entities_1.ProxyEntities.ReceiptType.CustomReceipt6,

 HardwareProfileId: hardwareProfile.ProfileId

};

Step 2. In CRT create new SingleRequestHandler

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LAW
{
    namespace Runtime.Extensions.PrintBillEndTranssaction
    {
        using System.Collections.Generic;
        using System.Collections.ObjectModel;
        using Microsoft.Dynamics.Commerce.Runtime;
        using Microsoft.Dynamics.Commerce.Runtime.DataModel;
        using Microsoft.Dynamics.Commerce.Runtime.Messages;
        using Microsoft.Dynamics.Commerce.Runtime.Services.Messages;
        using Microsoft.Dynamics.Commerce.Runtime.Workflow;
        using Microsoft.Dynamics.Commerce.Runtime.DataServices.Messages;
        using Microsoft.Dynamics.Commerce.Runtime.Data;
        /// 
        /// The request handler for GetCustomReceiptsRequestHandler class.
        /// 
        public class GetCustomReceiptsRequestHandler : SingleRequestHandler
        {

            /// 
            /// Processes the GetCustomReceiptsRequest to return the set of receipts. The request should not be null.
            /// 

            /// The request parameter.

            /// The GetReceiptResponse.

            protected override GetReceiptResponse Process(GetCustomReceiptsRequest request)
            {
                decimal PRINT2SALESINV = 0;
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.ReceiptRetrievalCriteria, "request.ReceiptRetrievalCriteria");

                // The sales order that we are printing receipts for is retrieved.
                SalesOrder salesOrder = this.GetSalesOrderForTransactionWithId(request.RequestContext, request.TransactionId);

                // Custom receipts are printed.
                Collection result = new Collection();
                switch (request.ReceiptRetrievalCriteria.ReceiptType)
                {
                    // An example of getting custom receipts.
                    case ReceiptType.CustomReceipt6:
                        {
                            var queryEXTCustTable = new SqlPagedQuery(QueryResultSettings.SingleRecord)
                            {
                                DatabaseSchema = "ext",
                                Select = new ColumnSet(new string[] { "LAW_BUSSTYLE", "LAW_PRINT2SALESINVOICE", "ACCOUNTNUM" }),
                                From = "LAW_CUSTTABLE",
                                Where = "ACCOUNTNUM = @ACCOUNTNUM AND DATAAREAID = @DATAAREAID"
                            };

                            queryEXTCustTable.Parameters["@ACCOUNTNUM"] = salesOrder.CustomerId;
                            queryEXTCustTable.Parameters["@DATAAREAID"] = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;


                            //Step 2. Select in 2 table

                            using (DatabaseContext databaseContext = new DatabaseContext(request.RequestContext))
                            {
                                ExtensionsEntity extensions = databaseContext.ReadEntity(queryEXTCustTable).FirstOrDefault();

                                if (extensions != null)
                                {
                                    var print2Invoice = extensions != null ? extensions.GetProperty("LAW_PRINT2SALESINVOICE") : 0;
                                    PRINT2SALESINV = Convert.ToDecimal(print2Invoice);
                                }
                            }

                            if (PRINT2SALESINV == 1)
                            {
                                IEnumerable customReceipts = this.GetCustomReceipts(salesOrder, request.ReceiptRetrievalCriteria);
                                result.AddRange(customReceipts);
                            }
                        }
                        break;
                    case ReceiptType.CustomReceipt20:
                        {
                            Receipt tempReceipt = new Receipt();
                            Collection tempReceiptCollection = new Collection();

                            tempReceipt.Printers = this.GetPrinterForHardcodeReceipt(request.RequestContext, request.ReceiptRetrievalCriteria.HardwareProfileId, ReceiptType.SalesReceipt);
                            tempReceiptCollection.Add(tempReceipt);

                            IEnumerable customReceipts = tempReceiptCollection;

                            result.AddRange(customReceipts);
                        }

                        break;
                    default:
                        break;
                }
                return new GetReceiptResponse(new ReadOnlyCollection(result));
            }

            /// 
            /// Gets a sales order for the transaction with the given identifier.
            ///             private SalesOrder GetSalesOrderForTransactionWithId(RequestContext requestContext, string transactionId)
            {
                SalesOrder salesOrder = new SalesOrder();

                var getCartRequest = new GetSalesOrderDetailsByTransactionIdServiceRequest(transactionId, SearchLocation.Local);

                var getCartResponse = requestContext.Execute(getCartRequest);
                salesOrder = getCartResponse.SalesOrder;

                return salesOrder;
            }

            private Collection GetCustomReceipts(SalesOrder salesOrder, ReceiptRetrievalCriteria criteria)
            {
                Collection result = new Collection();
                var getReceiptServiceRequest = new GetReceiptServiceRequest(
                    salesOrder,
                    new Collection { criteria.ReceiptType },
                    salesOrder.TenderLines,
                    criteria.IsCopy,
                    criteria.IsPreview,
                    criteria.HardwareProfileId);
                ReadOnlyCollection customReceipts = this.Context.Execute(getReceiptServiceRequest).Receipts;
                result.AddRange(customReceipts);
                return result;
            }

            private ReadOnlyCollection GetPrinters(RequestContext context, string hardwareProfileId, ReceiptType receiptType)
            {
                Terminal terminal = context.GetTerminal();
                if (string.IsNullOrEmpty(hardwareProfileId))
                {
                    hardwareProfileId = terminal.HardwareProfile;
                }

                GetPrintersDataRequest getPrintersByReceiptTypeDataRequest = new GetPrintersDataRequest(terminal.TerminalId, receiptType, QueryResultSettings.AllRecords, hardwareProfileId);
                IEnumerable printers = context.Execute>(getPrintersByReceiptTypeDataRequest).PagedEntityCollection.Results;
                Printer printer = printers.FirstOrDefault(p => p.PrinterType == (int)DeviceType.WindowsPrinter);

                return new List() { printer }.AsReadOnly();
            }

            private ReadOnlyCollection GetPrinterForHardcodeReceipt(RequestContext context, string hardwareProfileId, ReceiptType receiptType)
            {
                Terminal terminal = context.GetTerminal();
                if (string.IsNullOrEmpty(hardwareProfileId))
                    hardwareProfileId = terminal.HardwareProfile;
                GetHardwareProfileDataRequest profileDataRequest = new GetHardwareProfileDataRequest(hardwareProfileId, QueryResultSettings.SingleRecord);
                HardwareProfile entity = context.Runtime.Execute>((Request)profileDataRequest, context).Entity;
                if (entity != null && entity.Printers != null && entity.Printers.Any())
                {
                    HardwareProfilePrinter hardwareProfilePrinter = entity.Printers.FirstOrDefault((Func)(printer => (uint)printer.DeviceType > 0U));
                    if (hardwareProfilePrinter != null)
                        return new List()
                {
                    new Printer()
                    {
                      ReceiptType = receiptType,
                      PrintBehavior = PrintBehavior.Always,
                      Terminal = terminal == null ? 0L : terminal.RecordId,
                      HardwareProfileId = hardwareProfileId,
                      Name = hardwareProfilePrinter.DeviceName,
                      PrinterType = (int) hardwareProfilePrinter.DeviceType
                    }
                }.AsReadOnly();
                }
                return new List().AsReadOnly();
            }
        }
    }
}

Solution:  from my Technical Architect  in company.
Utilities to query in retail transaction table
Utilities to query in retail transaction table
Song Nghia - Technical Consultant


var queryRetailTransactionTable = new SqlPagedQuery(QueryResultSettings.SingleRecord)

 public void getRegulerDataInShift(Receipt receipt, RequestContext context, Shift shift, SingleEntityDataServiceResponse deviceConfiguration)
 {
  XReadingData.STORE = shift.StoreId;
  XReadingData.TERMINALID = terminal.TerminalId;
  XReadingData.SHIFT = shift.ShiftId.ToString();
  XReadingData.BEGININGBALANCE = globalLastShiftBalance;
  XReadingData.XREPORTID = XReadingNumber;
  XReadingData.NOOFTRANSACTION = shift.SaleTransactionCount;
  XReadingData.ROUNDING = shift.RoundedAmountTotal;
  XReadingData.NOOFABORTED = shift.VoidedSalesTotal;
  XReadingData.DOCNUM = XReadingNumber;
  XReadingData.TIN = deviceConfiguration.Entity.TaxIdNumber;
  XReadingData.STAFFNAME = this.GetEmployeeByStaffId(shift).Entity.Name;
  XReadingData.DATAAREAID = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  bool flag1 = shift.OverShortTotal < Decimal.Zero;
  if (flag1)
   XReadingData.SHORTAMOUNT = shift.OverShortTotal;
  else
   XReadingData.OVERAMOUNT = shift.OverShortTotal;
  XReadingData.COMPANYADDRESS = "11th Floor, Times Plaza Building, U.N. Avenue, corner Taft Ave, Manila, 1004 Metro Manila";
  XReadingData.COMPANYNAME = "LAWSON PHILIPPINES INC.";
  XReadingData.NOOFPAYINGCUST = shift.SaleTransactionCount + shift.CustomerCount;
  XReadingData.NETSALES = XReadingData.NETSALES + XReadingData.VATAMOUNT;
  XReadingData.ENDINGBALANCE = globalLastShiftBalance + XReadingData.NETSALES;//NS
  XReadingData.NOOFLOGON = shift.LogOnTransactionCount;
  XReadingData.GROSSSALES += XReadingData.RETURNAMOUNT;
 }
 public void getAllItemSoldAndReturn(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryRetailTransactionTable = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet(new string[] { "TRANSACTIONID", "NETAMOUNT", "TYPE", "ENTRYSTATUS", "RECEIPTID", "NUMBEROFITEMS" }),
   From = "RETAILTRANSACTIONTABLE",
   Where = "BATCHID = @BATCHID AND CHANNEL = @CHANNEL AND STORE = @STORE AND TERMINAL = @TERMINAL AND DATAAREAID = @DATAAREAID"
  };

  queryRetailTransactionTable.Parameters["@BATCHID"] = shift.ShiftId;
  queryRetailTransactionTable.Parameters["@TERMINAL"] = terminal.TerminalId;
  queryRetailTransactionTable.Parameters["@STORE"] = shift.StoreId;
  queryRetailTransactionTable.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryRetailTransactionTable.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   var extensions = databaseContext.ReadEntity(queryRetailTransactionTable);
   //LOOP all retail transaction in shift
   foreach (ExtensionsEntity extension in extensions)
   {
    //Get data in transaction
    string transactionId = extension.GetProperty("TRANSACTIONID").ToString();
    this.sumDiscountAmountWithDiscountType(transactionId);
    this.sumVatAdjustByGroupName(transactionId);
    this.GetSalesTypeBreakDownAndAmountTotal(transactionId);
    this.specialDiscountZeroRated(transactionId);
    #region RECEIPTID
    if (decimal.Parse(extension.GetProperty("ENTRYSTATUS").ToString()) == 0 && decimal.Parse(extension.GetProperty("TYPE").ToString()) == 2)
    {
     var queryTotalItemSold = new SqlPagedQuery(QueryResultSettings.SingleRecord)
     {
      DatabaseSchema = "ax",
      Select = new ColumnSet("QTY"),
      From = "RETAILTRANSACTIONSALESTRANS",
      Where = "QTY < 0 AND TRANSACTIONSTATUS = 0  AND CHANNEL = @CHANNEL AND STORE = @STORE AND TERMINALID = @TERMINALID AND TRANSACTIONID = @TRANSACTIONID AND DATAAREAID = @DATAAREAID"
     };

     queryTotalItemSold.Parameters["@CHANNEL"] = terminal.ChannelId; ;
     queryTotalItemSold.Parameters["@STORE"] = shift.StoreId;
     queryTotalItemSold.Parameters["@TERMINALID"] = shift.TerminalId;
     queryTotalItemSold.Parameters["@TRANSACTIONID"] = transactionId;
     queryTotalItemSold.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
     using (DatabaseContext databaseContextD = new DatabaseContext(originalReceiptsRequest.RequestContext))
     {
      foreach (ExtensionsEntity totalItemSold in databaseContextD.ReadEntity(queryTotalItemSold))
      {
       XReadingData.NUMBEROFITEMSOLD += (-1) * decimal.Parse(totalItemSold.GetProperty("QTY").ToString());
      }
     }
    }


    if (decimal.Parse(extension.GetProperty("NETAMOUNT").ToString()) > 0)
    {
     XReadingData.NOOFRETURN++;
    }
    #endregion
   }
  }
 }
 public void getEndingSalesInvoice(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryReatailTransactionDESC = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet("TRANSACTIONID", "TRANSDATE", "RECEIPTID"),
   From = "RETAILTRANSACTIONTABLE",
   OrderBy = "TRANSDATE DESC, TRANSTIME DESC",
   Where = "ENTRYSTATUS = 0  AND TYPE = 2 AND CHANNEL = @CHANNEL AND BATCHID = @BATCHID AND STORE = @STORE AND TERMINAL = @TERMINAL  AND  NETAMOUNT < 0 AND DATAAREAID = @DATAAREAID"
  };

  queryReatailTransactionDESC.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransactionDESC.Parameters["@BATCHID"] = shift.ShiftId;
  queryReatailTransactionDESC.Parameters["@STORE"] = shift.StoreId;
  queryReatailTransactionDESC.Parameters["@TERMINAL"] = terminal.TerminalId;
  queryReatailTransactionDESC.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensionsField = databaseContext.ReadEntity(queryReatailTransactionDESC).FirstOrDefault();
   if (extensionsField != null)
   {
    XReadingData.ENDINGSALESINVOICENO = extensionsField.GetProperty("RECEIPTID").ToString();
   }
  }

 }
 public void getBeginingSalesReturn(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryReatailTransactionReturnASC = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet("TRANSACTIONID", "TRANSDATE", "RECEIPTID"),
   From = "RETAILTRANSACTIONTABLE",
   OrderBy = "TRANSDATE ASC, TRANSTIME ASC",
   Where = "TYPE = 2 AND CHANNEL = @CHANNEL AND BATCHID = @BATCHID AND STORE = @STORE AND TERMINAL = @TERMINAL AND NETAMOUNT >= 0  AND DATAAREAID = @DATAAREAID"
  };

  queryReatailTransactionReturnASC.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransactionReturnASC.Parameters["@BATCHID"] = shift.ShiftId;
  queryReatailTransactionReturnASC.Parameters["@STORE"] = shift.StoreId;
  queryReatailTransactionReturnASC.Parameters["@TERMINAL"] = terminal.TerminalId;
  queryReatailTransactionReturnASC.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensionsField = databaseContext.ReadEntity(queryReatailTransactionReturnASC).FirstOrDefault();
   if (extensionsField != null)
   {
    XReadingData.BEGINNINGRETURNNO = extensionsField.GetProperty("RECEIPTID").ToString();
   }
  }
 }
 public void getEndingSalesReturn(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryReatailTransactionReturnDESC = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet("TRANSACTIONID", "TRANSDATE", "RECEIPTID"),
   From = "RETAILTRANSACTIONTABLE",
   OrderBy = "TRANSDATE DESC, TRANSTIME DESC",
   Where = "TYPE = 2 AND CHANNEL = @CHANNEL AND BATCHID = @BATCHID AND STORE = @STORE AND TERMINAL = @TERMINAL AND NETAMOUNT >= 0  AND DATAAREAID = @DATAAREAID"
  };

  queryReatailTransactionReturnDESC.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransactionReturnDESC.Parameters["@BATCHID"] = shift.ShiftId;
  queryReatailTransactionReturnDESC.Parameters["@STORE"] = shift.StoreId;
  queryReatailTransactionReturnDESC.Parameters["@TERMINAL"] = terminal.TerminalId;
  queryReatailTransactionReturnDESC.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensionsField = databaseContext.ReadEntity(queryReatailTransactionReturnDESC).FirstOrDefault();
   if (extensionsField != null)
   {
    XReadingData.ENDINGRETURNNO = extensionsField.GetProperty("RECEIPTID").ToString();
   }
  }
 }
 public void getBeginingSalesInvoice(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryReatailTransactionASC = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet("TRANSACTIONID", "TRANSDATE", "RECEIPTID"),
   From = "RETAILTRANSACTIONTABLE",
   OrderBy = "TRANSDATE ASC, TRANSTIME ASC",
   Where = "ENTRYSTATUS = 0 AND  TYPE = 2 AND CHANNEL = @CHANNEL AND BATCHID = @BATCHID AND STORE = @STORE AND TERMINAL = @TERMINAL AND  NETAMOUNT <0 and="" atabasecontext="" dataareaid="@DATAAREAID" databasecontext="" extensionsentity="" extensionsfield="databaseContext.ReadEntity<ExtensionsEntity" nventlocationdataareaid="" originalreceiptsrequest.requestcontext.getchannelconfiguration="" originalreceiptsrequest.requestcontext="" queryreatailtransactionasc.parameters="" shift.shiftid="" shift.storeid="" terminal.channelid="" terminal.terminalid="" using="">(queryReatailTransactionASC).FirstOrDefault();
   if (extensionsField != null)
   {
    XReadingData.BEGINNINGSALESINVOICENO = extensionsField.GetProperty("RECEIPTID").ToString();
   }
  }
 }
 public void getTerminalDetail(Receipt receipt, RequestContext context, Shift shift)
 {
  var queryRetailTerminal = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet(new string[] {
   "LAW_MACHINEIDENTIFICATIONNUMBER",
   "LAW_MACHINESERIALNUMBER",
   "LAW_PERMITTOUSENUMBER",
   "LAW_PTUDATEISSUED",
   "LAW_PTUVALIDTO",
   "LAW_ACCREDITATIONNUMBER",
   "LAW_ACCDTNDATEISSUED",
   "LAW_ACCDTNVALIDTO",
   "TERMINALID" }),
   From = "LAW_RETAILTERMINALTABLE",
   Where = "TERMINALID = @TERMINALID"
  };

  queryRetailTerminal.Parameters["@TERMINALID"] = originalReceiptsRequest.RequestContext.GetTerminal().TerminalId;
  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensions = databaseContext.ReadEntity(queryRetailTerminal).FirstOrDefault();

   if (extensions != null)
   {
    //Header 1.5 
    XReadingData.MIN = extensions.GetProperty("LAW_MACHINESERIALNUMBER").ToString();
    //Header 1.6
    XReadingData.SN = extensions.GetProperty("LAW_MACHINESERIALNUMBER").ToString();

   }
  }
 }
 public void getDateTimeShiftAndReportName(Receipt receipt, RequestContext context, Shift shift)
 {
  string str1 = string.Empty;
  string str2 = string.Empty;
  string str3 = string.Empty;
  string str4 = string.Empty;

  if (shift.StartDateTime.HasValue)
  {
   if (receipt.ReceiptType == ReceiptType.ZReport)
   {
    str1 = this.FormatDate(shift.StartDateTime, context);
    str2 = this.FormatTime(shift.StartDateTime, TimeFormattingType.SystemLongTime, context);
   }
   else
   {
    str1 = this.FormatDate(shift.StartDateTime, context);
    str2 = this.FormatTime(shift.StartDateTime, TimeFormattingType.SystemLongTime, context);
   }
  }
  XReadingData.ACTUALDATE = DateTime.Parse(str1);

  DateTime t = DateTime.ParseExact(str2, "h:mm:ss tt", CultureInfo.InvariantCulture);
  //if you really need a TimeSpan this will get the time elapsed since midnight:
  TimeSpan ts = t.TimeOfDay;

  XReadingData.ACTUALTIME = ts;
  if (shift.CloseDateTime.HasValue)
  {
   str3 = this.FormatDate(shift.CloseDateTime, context);
   str4 = this.FormatTime(shift.CloseDateTime, TimeFormattingType.SystemLongTime, context);
  }
  string empty = string.Empty;

  string str5;
  if (receipt.ReceiptType != ReceiptType.XReport)
  {
   if (receipt.ReceiptType != ReceiptType.ZReport)
    throw new NotSupportedException(string.Format("Unsupported Report Type '{0}'.", (object)receipt.ReceiptType));
   str5 = shift.StaffId;
   XReadingData.REPORTNAME = "X-Reading Report";
  }
  else
  {
   str5 = context.GetPrincipal().UserId;
   XReadingData.REPORTNAME = "Tender Report";
  }
 }
 public class DistcountEntity
 {
  public string DiscountStr { get; set; }
  public decimal DiscountDecimal { get; set; }

  public DistcountEntity(string _discountType, decimal _discountAmount)
  {
   DiscountStr = _discountType;
   DiscountDecimal = _discountAmount;
  }
 }
 public void sumVatAdjustByGroupName(string transactionId)
 {
  var queryReatailTransDiscountGroupName = new SqlPagedQuery(QueryResultSettings.AllRecords)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet("DISCOUNTGROUPNAME", "TRANSACTIONID", "SALELINENUM"),
   From = "LAW_RETAILTRANSDISCOUNTGROUPBYGROUPNAMEVIEW",
   Where = "DATAAREAID = @DATAAREAID AND TRANSACTIONID = @TRANSACTIONID AND TERMINALID = @TERMINALID AND STOREID = @STOREID AND CHANNEL = @CHANNEL"
  };
  queryReatailTransDiscountGroupName.Parameters["@TERMINALID"] = shift.TerminalId;
  queryReatailTransDiscountGroupName.Parameters["@STOREID"] = shift.StoreId;
  queryReatailTransDiscountGroupName.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransDiscountGroupName.Parameters["@TRANSACTIONID"] = transactionId;
  queryReatailTransDiscountGroupName.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   var extensions = databaseContext.ReadEntity(queryReatailTransDiscountGroupName);

   //LOOP all record on RETAILTRANSACTIONDISCOUNTTRANSEXTEND
   foreach (ExtensionsEntity extension in extensions)
   {
    decimal SALELINENUM = decimal.Parse(extension.GetProperty("SALELINENUM").ToString());
    string discountGroupName = extension.GetProperty("DISCOUNTGROUPNAME").ToString();
    decimal DiscountValue = this.sumDataInRetailTransactionTableExt(transactionId, SALELINENUM);
    listVATAdjustDiscountGroup.Add(new DistcountEntity(discountGroupName, (-1) * DiscountValue));
   }
  }
 }
 public void specialDiscountZeroRated(string transactionId)
 {
  decimal zeroDiscount = 0;
  var queryReatailTableTrans = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet("LAW_VATADJUSTMENT"),
   From = "LAW_RETAILTRANSACTIONSALESLINEEXTEND",
   Where = "LAW_ZERORATEDSALESAMOUNT != 0  AND DATAAREAID = @DATAAREAID AND CHANNEL = @CHANNEL AND TERMINALID = @TERMINALID AND TRANSACTIONID = @TRANSACTIONID AND STOREID = @STOREID"
  };

  queryReatailTableTrans.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTableTrans.Parameters["@STOREID"] = shift.StoreId;
  queryReatailTableTrans.Parameters["@TERMINALID"] = terminal.TerminalId;
  queryReatailTableTrans.Parameters["@TRANSACTIONID"] = transactionId;
  queryReatailTableTrans.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContextField = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   var extensionsFields = databaseContextField.ReadEntity(queryReatailTableTrans);
   foreach (ExtensionsEntity extensionsField in extensionsFields)
    zeroDiscount += decimal.Parse(extensionsField.GetProperty("LAW_VATADJUSTMENT").ToString());
  }
  XReadingData.ZERORATEDDISCOUNT += (-1) * zeroDiscount;


 }
 public decimal sumDataInRetailTransactionTableExt(string transactionId, decimal salesLineNum)
 {
  decimal VATAdjust = 0;
  var queryReatailTableTrans = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet("LAW_VATADJUSTMENT"),
   From = "LAW_RETAILTRANSACTIONSALESLINEEXTEND",
   Where = "SALESLINENUM = @SALESLINENUM  AND DATAAREAID = @DATAAREAID AND CHANNEL = @CHANNEL AND TERMINALID = @TERMINALID AND TRANSACTIONID = @TRANSACTIONID AND STOREID = @STOREID"
  };

  queryReatailTableTrans.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTableTrans.Parameters["@STOREID"] = shift.StoreId;
  queryReatailTableTrans.Parameters["@TERMINALID"] = terminal.TerminalId;
  queryReatailTableTrans.Parameters["@TRANSACTIONID"] = transactionId;
  queryReatailTableTrans.Parameters["@SALESLINENUM"] = salesLineNum;
  queryReatailTableTrans.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContextField = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensionsFields = databaseContextField.ReadEntity(queryReatailTableTrans).FirstOrDefault();

   VATAdjust = decimal.Parse(extensionsFields.GetProperty("LAW_VATADJUSTMENT").ToString());
  }
  return VATAdjust;
 }
 public void sumDiscountAmountWithDiscountType(string transactionId)
 {
  var queryReatailTransDiscountTransExtend = new SqlPagedQuery(QueryResultSettings.AllRecords)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet("DISCOUNTTYPE", "TRANSACTIONID", "SALELINENUM"),
   From = "LAW_RETAILTRANSDISCOUNTGROUPBYDISCOUNTTYPEVIEW",
   Where = "DATAAREAID = @DATAAREAID AND TRANSACTIONID = @TRANSACTIONID AND TERMINALID = @TERMINALID AND STOREID = @STOREID AND CHANNEL = @CHANNEL"
  };
  queryReatailTransDiscountTransExtend.Parameters["@TERMINALID"] = shift.TerminalId;
  queryReatailTransDiscountTransExtend.Parameters["@STOREID"] = shift.StoreId;
  queryReatailTransDiscountTransExtend.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransDiscountTransExtend.Parameters["@TRANSACTIONID"] = transactionId;
  queryReatailTransDiscountTransExtend.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   var extensions = databaseContext.ReadEntity(queryReatailTransDiscountTransExtend);

   //LOOP all record on RETAILTRANSACTIONDISCOUNTTRANSEXTEND
   foreach (ExtensionsEntity extension in extensions)
   {
    decimal SALELINENUM = decimal.Parse(extension.GetProperty("SALELINENUM").ToString());
    string discountType = extension.GetProperty("DISCOUNTTYPE").ToString();
    decimal DiscountValue = this.getDiscountAmountBaseOnDiscountType(transactionId, SALELINENUM);
    listDiscountType.Add(new DistcountEntity(discountType, (-1) * DiscountValue));
   }
  }
 }
 public decimal getDiscountAmountBaseOnDiscountType(string transactionId, decimal salesLineNum)
 {
  decimal discountAmt = 0;

  var queryReatailTransSalesTransExt = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ax",
   Select = new ColumnSet("TERMINALID", "TRANSACTIONID", "STORE", "LINENUM", "CHANNEL", "DISCAMOUNTWITHOUTTAX"),
   From = "RETAILTRANSACTIONSALESTRANS",
   Where = "LINENUM = @SALESLINENUM AND DATAAREAID = @DATAAREAID AND CHANNEL = @CHANNEL AND TERMINALID = @TERMINALID AND TRANSACTIONID = @TRANSACTIONID AND STORE = @STORE"
  };

  queryReatailTransSalesTransExt.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryReatailTransSalesTransExt.Parameters["@STORE"] = shift.StoreId;
  queryReatailTransSalesTransExt.Parameters["@TERMINALID"] = terminal.TerminalId;
  queryReatailTransSalesTransExt.Parameters["@TRANSACTIONID"] = transactionId;
  queryReatailTransSalesTransExt.Parameters["@SALESLINENUM"] = salesLineNum;
  queryReatailTransSalesTransExt.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

  using (DatabaseContext databaseContextField = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   ExtensionsEntity extensionsField = databaseContextField.ReadEntity(queryReatailTransSalesTransExt).FirstOrDefault();
   if (extensionsField != null)
   {
    //Get discount amount
    discountAmt = decimal.Parse(extensionsField.GetProperty("DISCAMOUNTWITHOUTTAX").ToString());
   }
  }
  return discountAmt;
 }
 public void GetSalesTypeBreakDownAndAmountTotal(string transactionId)
 {
  decimal ZeroRatedSalesAmount = 0;
  decimal VATableSalesAmount = 0;
  decimal VATExemptSalesAmount = 0;

  decimal ZeroRatedSalesVATAmount = 0;
  decimal VATableSales = 0;
  decimal VATExemptSales = 0;

  decimal NetSales = 0;
  decimal Grosssales = 0;
  decimal ReturnAmount = 0;

  var queryRetailTransactionTable = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   DatabaseSchema = "ext",
   Select = new ColumnSet(new string[] { "LAW_VATEXEMPTSALESVATAMOUNT", "LAW_ZERORATEDSALESVATAMOUNT", "LAW_VATABLESSALESAMOUNT", "LAW_VATABLESSALESVATAMOUNT", "TRANSACTIONID", "LAW_VATEXEMPTSALESAMOUNT", "LAW_ZERORATEDSALESAMOUNT", "LAW_NETSALES", "LAW_LPITOTAL" }),
   From = "LAW_RETAILTRANSACTIONTABLEEXTEND",
   Where = "TRANSACTIONID = @TRANSACTIONID AND CHANNEL = @CHANNEL AND STOREID = @STOREID  AND DATAAREAID = @DATAAREAID"
  };

  queryRetailTransactionTable.Parameters["@STOREID"] = shift.StoreId;
  queryRetailTransactionTable.Parameters["@TRANSACTIONID"] = transactionId;
  queryRetailTransactionTable.Parameters["@CHANNEL"] = terminal.ChannelId;
  queryRetailTransactionTable.Parameters["@DATAAREAID"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  using (DatabaseContext databaseContextField = new DatabaseContext(originalReceiptsRequest.RequestContext))
  {
   var extensionsField = databaseContextField.ReadEntity(queryRetailTransactionTable);
   foreach (ExtensionsEntity extension in extensionsField)
   {
    //Get discount amount
    VATableSalesAmount += decimal.Parse(extension.GetProperty("LAW_VATABLESSALESAMOUNT").ToString());
    VATableSales += decimal.Parse(extension.GetProperty("LAW_VATABLESSALESVATAMOUNT").ToString());
    VATExemptSalesAmount += decimal.Parse(extension.GetProperty("LAW_VATEXEMPTSALESAMOUNT").ToString());
    VATExemptSales += decimal.Parse(extension.GetProperty("LAW_VATEXEMPTSALESVATAMOUNT").ToString());
    ZeroRatedSalesAmount += decimal.Parse(extension.GetProperty("LAW_ZERORATEDSALESAMOUNT").ToString());
    ZeroRatedSalesVATAmount += decimal.Parse(extension.GetProperty("LAW_ZERORATEDSALESVATAMOUNT").ToString());
    NetSales += decimal.Parse(extension.GetProperty("LAW_NETSALES").ToString());
    Grosssales += decimal.Parse(extension.GetProperty("LAW_LPITOTAL").ToString());

    if (decimal.Parse(extension.GetProperty("LAW_LPITOTAL").ToString()) > 0)
    {
     ReturnAmount += decimal.Parse(extension.GetProperty("LAW_LPITOTAL").ToString());
    }


   }

  }
  XReadingData.VATAMOUNT += (-1) * (VATableSales + VATExemptSales + ZeroRatedSalesVATAmount);

  //XReadingData.ZERORATEDSALESVATAMOUNT += (-1) * ZeroRatedSalesAmount;
  XReadingData.ZERORATEDSALES += (-1) * ZeroRatedSalesAmount;
  XReadingData.VATABLESALES += (-1) * VATableSalesAmount;
  XReadingData.VATEXEMPTSALES += (-1) * VATExemptSalesAmount;
  //nghia.song can remove code nay sao
  XReadingData.NETSALES += NetSales;
  XReadingData.GROSSSALES += (-1) * Grosssales;
  XReadingData.RETURNAMOUNT += ReturnAmount;




 }
 private SingleEntityDataServiceResponse GetEmployeeByStaffId(Shift shift)
 {
  SqlPagedQuery sqlPagedQuery = new SqlPagedQuery(QueryResultSettings.SingleRecord)
  {
   From = "GetEmployeeByStaffId(@nvc_StaffId, @nvc_DataAreaId)"
  };
  sqlPagedQuery.Parameters["@nvc_StaffId"] = shift.StaffId;
  sqlPagedQuery.Parameters["@nvc_DataAreaId"] = originalReceiptsRequest.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
  Employee entity1;
  using (DatabaseContext databaseContext = new DatabaseContext(originalReceiptsRequest.RequestContext))
   entity1 = databaseContext.ReadEntity((IDatabaseQuery)sqlPagedQuery).SingleOrDefault();
  if (entity1 != null)
  {
   ChannelConfiguration channelConfiguration = originalReceiptsRequest.RequestContext.GetChannelConfiguration();
   if (channelConfiguration != null)
    entity1.Images = RichMediaHelper.PopulateEmployeeMediaInformation(entity1.StaffId, entity1.ImageUri, channelConfiguration.EmployeeDefaultImageTemplate);
   else if (originalReceiptsRequest.RequestContext.GetPrincipal().ChannelId != 0L)
   {
    GetChannelConfigurationDataRequest configurationDataRequest = new GetChannelConfigurationDataRequest(originalReceiptsRequest.RequestContext.GetPrincipal().ChannelId);
    ChannelConfiguration entity2 = originalReceiptsRequest.RequestContext.Execute>((Request)configurationDataRequest).Entity;
    entity1.Images = RichMediaHelper.PopulateEmployeeMediaInformation(entity1.StaffId, entity1.ImageUri, entity2.EmployeeDefaultImageTemplate);
   }
  }
  return new SingleEntityDataServiceResponse(entity1);
 }
private SalesOrder GetSalesOrderForTransactionWithId(RequestContext requestContext, string transactionId)
{
 SalesOrder salesOrder = new SalesOrder();

 var getCartRequest = new GetSalesOrderDetailsByTransactionIdServiceRequest(transactionId, SearchLocation.Local);

 var getCartResponse = requestContext.Execute(getCartRequest);

 salesOrder = getCartResponse.SalesOrder;

 return salesOrder;
}

private string roundingCurrency(decimal value, string currencyCode, RequestContext context)
{
 GetRoundedValueServiceRequest roundingRequest = null;

 string currencySymbol = string.Empty;

 // Get the currency symbol.
 if (!string.IsNullOrWhiteSpace(currencyCode))
 {
  var getCurrenciesDataRequest = new GetCurrenciesDataRequest(currencyCode, QueryResultSettings.SingleRecord);
  Currency currency = context.Runtime.Execute>(getCurrenciesDataRequest, context).PagedEntityCollection.FirstOrDefault();
  currencySymbol = currency.CurrencySymbol;
 }

 roundingRequest = new GetRoundedValueServiceRequest(value, currencyCode, 0, false);

 decimal roundedValue = context.Execute(roundingRequest).RoundedValue;

 var formattingRequest = new GetFormattedCurrencyServiceRequest(roundedValue, currencySymbol);
 string formattedValue = context.Execute(formattingRequest).FormattedValue;
 return formattedValue;
}

Update version Onebox Virtual Machine Dynamic Retail 365
Update version Onebox Virtual machine 
Dynamic Retail 365

Song Nghia - Technical Consultant

1. Download upgrade package from LCS Asset Library
2. Check all version of combonent in update
Run cmd : AXUpdateInstaller.exe list

3. Extract upgrade package download from LCS
Remove any Space in folder name if have


4. Run command as administrator

AXUpdateInstaller.exe generate -runbookid="OneBoxDev" -topologyfile="DefaultTopologyData.xml" -servicemodelfile="DefaultServiceModelData.xml" -runbookfile="OneBoxDev-runbook.xml"

5. Run command as administrator

AXUpdateInstaller.exe import -runbookfile=OneBoxDev-runbook.xml


6. Run command as administrator 

AXUpdateInstaller.exe execute -runbookid=OneBoxDev

7. If fail steps, try to re run the steps
AXUpdateInstaller.exe execute -runbookid=OneBoxDev -rerunstep=12

8. Full Build all Model in Visual Studio

9. Full sync

10. copy all update in C:\Retail SDK\ Update\ Generate folder to retail SDK 

11. Restart VM

Solution:  from my Technical Architect  in company.
Change tracking must be enabled on database 'AxDB' before it can be enabled on table 'RETAILCHANNELTABLE'.

Change tracking must be enabled on database 'AxDB' before it can be enabled on table 'RETAILCHANNELTABLE'.

Song Nghia - Technical Consultant

Step 0. Change AXDB



Step 1. Script split string

/****** Object:  UserDefinedFunction [dbo].[SplitString]    Script Date: 11/19/2016 12:14:03 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[SplitString]
(    
      @Input NVARCHAR(MAX),
      @Character CHAR(1)
)
RETURNS @Output TABLE (
      Item NVARCHAR(max)
)
AS
BEGIN
      DECLARE @StartIndex INT, @EndIndex INT
 
      SET @StartIndex = 1
      IF SUBSTRING(@Input, LEN(@Input) - 1, LEN(@Input)) <> @Character
      BEGIN
            SET @Input = @Input + @Character
      END
 
      WHILE CHARINDEX(@Character, @Input) > 0
      BEGIN
            SET @EndIndex = CHARINDEX(@Character, @Input)
           
            INSERT INTO @Output(Item)
            SELECT SUBSTRING(@Input, @StartIndex, @EndIndex - 1)
           
            SET @Input = SUBSTRING(@Input, @EndIndex + 1, LEN(@Input))
      END
 
      RETURN
END

GO

Script enable tracking
DECLARE @ChangeTrackingTables NVARCHAR(MAX)
DECLARE @TableName NVARCHAR(250)
DECLARE @Sql NVARCHAR(500)

SET @ChangeTrackingTables = 'CUSTPARAMETERS,LOGISTICSLOCATION,USERINFO,RETAILPERMISSIONSEX,RETAILSTORETENDERTYPETABLE,TAXRUNTIMEDOCCOMPONENTMEASURE,RETAILONLINECHANNELPUBLISHSTATUS,FISCALESTABLISHMENTINVENTSITE_BR,RETAILREPORTPERMISSIONGROUP,LOGISTICSADDRESSPARAMETERS,RETAILDLVMODEPRODUCTLINE,RETAILCONFIGURATIONPARAMETERS,RETAILFUNCTIONALITYPROFILEFISCALINTEGRATIONTECHNICALPROFILELINE,RETAILPERMISSIONS,RETAILKITCOMPONENTSUBSTITUTE,ECORESENUMERATIONATTRIBUTETYPEVALUE,RETAILLOCALIZEDTEXT,RETAILSALESTAXOVERRIDEGROUPMEMBER,TAXRUNTIMEDOCCOMPONENTPOSTINGTYPE,RETAILTABLEIDTABLE,TAXREGISTRATIONLEGISLATIONTYPES,TAXRUNTIMEREFERENCEMODELROW,TAXRUNTIMEDOCMODELROWMEASURE,DIRPARTYLOCATIONROLE,TAXCOMPONENTTABLE_IN,LOGISTICSADDRESSSTATE,RETAILONLINECHANNELFUNCTIONALITYPROFILETABLE,TAXRUNTIMETAXTYPEVERSION,AGREEMENTHEADEREXT_RU,RETAILKITCOMPONENT,TAXRUNTIMEDOCMODELATTR,FISCALESTABLISHMENT_BR,LEDGERVOUCHERTYPE_CN,RETAILDLVMODEADDRESSEXPLODED,WHSLOCATIONPROFILE,MAINACCOUNTCATEGORY,RETAILEXTERNALIDTOCUSTOMERMAP,ERVENDORTABLE,SMMCAMPAIGNTABLE,FISCALCALENDARPERIOD,RETAILTILLLAYOUTSTORE,RETAILAFFILIATION,RETAILASSORTMENTLOOKUPCHANNELGROUP,RETAILOFFLINESCOPE,RETAILEVENTNOTIFICATIONPROFILE,INVENTITEMGROUP,TAXRUNTIMELOOKUPMEASURERESULT,LOGISTICSADDRESSFORMATHEADING,RETAILINCOMEEXPENSEACCOUNTTABLE,ERTEXTFORMATVERSIONTABLE,LOGISTICSADDRESSFORMATLINES,RETAILOFFLINETABLECOLUMNS,MARKUPAUTOTABLE,ECORESATTRIBUTEGROUP,GENERALJOURNALENTRY,RETAILPOSPERMISSIONGROUP,TAXRUNTIMEMODEL,ACCOUNTANT_BR,RETAILCUSTOMERSEARCHFIELD,TAXRUNTIMEDOCTAXTYPEPOSTINGTYPE,RETAILCOUPON,DIMENSIONATTRIBUTEVALUETOTALLINGCRITERIA,RETAILOFFLINETABLE,ECORESPRODUCTTRANSLATION,TAXSOLUTIONSCOPE,SHIPCARRIERSTAGING,PRICEPARAMETERS,LOGISTICSADDRESSCITY,LEDGERFUND,ECORESVALUE,RETAILSHAREDBINGPARAMETERS,PLFISCALTAXTABLE,TAXRUNTIMEREFERENCEMODELROWVERSION,INVENTITEMGTIN,TAXRUNTIMEDOCCOMPONENTMEASUREVERSION,RETAILKEYBOARDMAPPINGTABLE,DOCUVALUE,RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA,SYSTEMPARAMETERS,TAXRUNTIMECOMPONENTMEASURE,RETAILINVENTLINKEDITEM,TAXRUNTIMELOOKUPMEASURERESULTDETAIL,RETAILCHANNELREPORT,INVENTITEMBARCODE,SYSTASKRECORDERINDUSTRY,TAXRUNTIMEDOCMODELROWMEASUREVERSION,TAXRUNTIMEDOCMODELATTRVERSION,RETAILSTOREHOURSTEMPLATE,RETAILINFOCODEFISCALTEXT,RETAILRELYINGPARTY,RETAILTHEMEPALLET,RETAILTERMINALTABLE,ECORESPRODUCTMASTERDIMENSIONVALUE,TAXRUNTIMEMODELATTR,PROJTABLE,TAXRUNTIMELOOKUPSTRUCTUREFIELDVERSION,RETAILHARDWAREPROFILEFISCALINTEGRATIONTECHNICALPROFILELINE,RETAILCHANNELTABLE,LEDGERJOURNALTRANS,LOGISTICSADDRESSCOUNTRYREGION,RETURNREASONCODEGROUP,RETAILKITVARIANTCOMPONENT,RETAILINFORMATIONSUBCODETABLE,RETAILCHANNELPROFILE,ECORESCATEGORYTRANSLATION,ECORESATTRIBUTEDEFAULTVALUE,TAXSOLUTIONSCOPESETUP,ECORESATTRIBUTEVALUE,RETAILCHANNELCURRENCY,COMPANYDEFAULTLOCATION,RETAILTRANSACTIONORDERSTATUS,ECORESPRODUCTCATEGORY,RETAILSHIPCARRIERACCOUNTCONFIGURATION,TAXREGISTRATIONTYPEAPPLICABILITYRULE,BUDGETPLANHEADER,RETAILPUBCHANNELATTRIBUTE,RETAILLOYALTYSCHEMECHANNEL,RETAILPUBINTERNALORGATTRIBUTEGROUP,TAXPOVERTYFUNDSETUPDATA_BR,LOGISTICSADDRESSCOUNTY,RETAILSTORETENDERTYPECARDTABLE,HCMJOB,RETAILINFOCODETRANSLATION,DLVMODE,RETAILPUBCATALOG,PROVISIONINGMESSAGETABLE,RETAILLOYALTYSCHEME,INVENTDIMCOMBINATION,TAXRTDOCCOMPFORMULACOMPMEASURE,SERVICEACCOUNTINGCODETABLE_IN,RETAILPUBCATALOGPRODUCTCATEGORY,RETAILSPECIALCATEGORYMEMBER,MARKUPTABLE_IN,COMMISSIONSALESGROUP,ECORESSIZE,RETAILCOUPONCODETABLE,TAXRUNTIMEDOCMODELROW,TAXRUNTIMECOMPONENTMEASUREVERSION,TAXRUNTIMELOOKUPTAXCURRENCYRESULT,TAXRUNTIMELOOKUPSTRUCTUREVERSION,RETURNREASONCODE,RETAILSALESTAXOVERRIDE,TAXSUBSTITUTIONCODETABLE_BR,ECORESPRODUCTRELATIONTYPE,TAXRUNTIMEMODELATTRVERSION,HCMPOSITIONDETAIL,RETAILDISCOUNTVALIDATIONPERIOD,INVENTLOCATIONLOGISTICSLOCATIONROLE,TAXBURDEN_BR,TAXRUNTIMEDOCCOMPONENTPOSTINGPROFILE,RETAILPERIODICDISCOUNT,COMMISSIONSALESREP,RETAILDISCOUNTTHRESHOLDTIERS,RETAILSTORELOCATORGROUP,RETAILPUBRETAILCATALOGPRICEGROUP,RETAILDEVICE,ACCOUNTANTLOGISTICSLOCATION_BR,DIMENSIONATTRIBUTEVALUE,RETAILCHANNELTABLE_IN,JMGIPCACTIVITY,RETAILKEYBOARDMAPPINGTRANS,RETAILPERIODICDISCOUNTLINE,TAXRTDOCCOMPPOSTINGPROFDETVERSION,RETAILFISCALINTEGRATIONREGISTRATIONPROCESS,RETAILCUSTOMERSEARCHFIELDTRANSLATION,RETAILCATEGORYCONTAINMENTLOOKUP,LOGISTICSADDRESSZIPCODE,RETAILSHIPCARRIERINTERFACE,ECORESCATEGORYATTRIBUTEGROUP,DIMENSIONATTRVALUELEDGEROVERRIDE,ECORESATTRIBUTETYPE,CUSTGROUP,TAXRUNTIMELOOKUPVERSION,BUDGETTRANSACTIONLINE,ECORESPRODUCTIMAGE,RETAILLOYALTYREWARDPOINT,RETAILLOYALTYEARNSCHEMELINE,CUSTPACKINGSLIPJOUR,BUDGETSOURCETRACKINGRELIEVINGDETAIL,TAXPOVERTYFUNDSETUPHEADING_BR,ECORESTEXTVALUETRANSLATION,RETAILCDXDATASTORECHANNEL,ECORESPRODUCTRELATIONTABLE,RETAILATTACHEDSERVICEMASTER,RETAILAFFILIATIONPRICEGROUP,TAXRUNTIMELOOKUPACCOUNTINGRESULT,TAXRUNTIMEDOCCOMPONENTPOSTINGPROFILEDET,TAXRUNTIMEREFERENCEMODEL,ECORESBOUNDEDATTRIBUTETYPEVALUE,RETAILFISCALINTEGRATIONREGISTRATIONPROCESSLINE,RETAILTENDERTYPETABLE,TAXRUNTIMEDOCMODELROWVERSION,RETAILDISCOUNTFISCALTEXT,OMEXPLODEDORGANIZATIONSECURITYGRAPH,TAXREGISTRATIONTYPE,TAXRUNTIMECOMPONENTVERSION,LEDGER,RETAILNOTIFICATIONSUBSCRIPTIONS,RETAILPUBCATALOGPRODUCTRELATION,RETAILSERVERRESOURCE,RETAILLOYALTYREDEEMSCHEMELINE,EFDOCWEBSERVICEPARAMETERS_BR,RETAILMIXANDMATCHLINEGROUPS,INVENTTABLE,TAXDOCUMENTROWMEASUREADJUSTMENT,INVENTITEMSALESSETUP,DIMENSIONATTRIBUTEVALUECOMBINATION,RETAILDRAWERPOOLDEVICE,EXCHANGERATECURRENCYPAIR,BUDGETMODEL,WHSINVENTSTATUS,RETAILKITRELEASEDSUBSTITUTECHARGE,RETAILPUBECORESCATEGORY,RETAILSTORESAFE,ERSOLUTIONVERSIONTABLE,RETAILDRAWERPOOL,TAXRUNTIMEREFERENCEMODELVERSION,RETAILSHAREDPARAMETERS,RETAILRECEIPTPROFILE,RETAILGROUPMEMBERLINE,RETAILSTORELOCATORGROUPMEMBER,RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE,TAXRUNTIMELOOKUPTAXPERIODRESULT,TAXRUNTIMELOOKUPACCOUNTINGRESULTDETAIL,BUDGETPLANNINGPROCESS,DIRADDRESSBOOK,RETAILUNIT,RETAILDISCOUNTCODE,RETAILFISCALINTEGRATIONCONNECTORTABLE,RETAILPERMISSIONSGROUP,RETAILLOYALTYCARDTIER,RETAILTILLLAYOUTZONE,LOGISTICSPOSTALADDRESS,RETAILPOSTHEME,RETAILSTOREHOURSCHANNEL,TAXRTDOCCOMPPOSTINGPROFVERSION,RETAILHARDWAREPROFILE,LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION,RETAILPUBCATALOGTRANSLATION,TAXRUNTIMEDEFCONTEXT,INVENTSITEDEFAULTLOCATION,INVENTDIM,RETAILKEYBOARDBUTTONCONTROLB,LEDGERCOV,RETAILCHANNELPROFILEPROPERTY,INVENTSITELOGISTICSLOCATIONROLE,RETAILLABELCHANGEJOURNALTRANS,LANGUAGETABLE,RETAILTILLLAYOUTZONEREFERENCE,RETAILINVENTAVAILABILITYPARAMETERS,ERSOLUTIONTABLE,RETAILCHANNELPAYMENTCONNECTORLINE,RETAILTERMINALDEVICE,BUDGETPLANPRIORITY,TAXRUNTIMEMODELROW,RETAILLOYALTYTIERTRANSLATION,TAXRUNTIMEDOCMODELVERSION,ECORESPRODUCT,RETAILRECEIPTPROFILELINE,DIMENSIONATTRIBUTE,RETAILTABLEFIELDID,TAXCOLLECTLIMIT,INVENTLOCATIONLOGISTICSLOCATION,RETAILLOYALTYTIER,TAXPARAMETERS,RETAILPUBINTORGINHERITANCEEXPLODED,UNITOFMEASURECONVERSION,RETAILCHANNELATTRIBUTEGROUP,RETAILLOYALTYCARD,RETAILSTORECASHDECLARATIONTABLE,RETAILTAXFILTERS,TAXRUNTIMELOOKUP,RETAILINFOCODE,MAINACCOUNTLEGALENTITY,SYSSERVICECONFIGURATIONSETTING,RETAILBARCODEMASKCHARACTER,RETAILDEVICETYPES,TAXATIONCODESETUP_BR,TAXRTLOOKUPSTRUCTFIELDBINDINGVERSION,RETAILDLVMODEPRODUCTEXPLODED,ECORESCOLOR,ECORESSTYLE,SYSTASKRECORDERLINEARTIFACT,RETAILCONNDATABASEPROFILE,TAXDATA,TAXRUNTIMEDEFCONTEXTVERSION,DIRADDRESSBOOKPARTY,RETAILPUBPRODUCTATTRIBUTEVALUE,ECORESPRODUCTVARIANTDIMENSIONVALUE,RETAILLOYALTYOTHERACTIVITYTYPE,TAXATIONCODETABLE_BR,RETAILTILLLAYOUTSTAFF,RETAILINVENTAVAILABILITY,RETAILVISUALPROFILE,DOCUREF,RETAILPARAMETERS,ACCOUNTANTLOGISTICSLOCATIONROLE_BR,RETAILOFFLINEPROFILESCOPES,RETAILINFOCODETABLE,TAXENGINESQLDICTIONARY,ERDATAMODELVERSIONTABLE,SYSTASKRECORDERPARAMETERS,TAXRUNTIMEDOCTAXTYPE,TAXBRANCH,RETAILFISCALINTEGRATIONTECHNICALPROFILE,TAXBENEFITCODESETUPDATA_BR,RETAILCONFIGURATION_BR,RETAILPOSITIONNOTIFICATIONSUBSCRIPTIONS,FBFISCALDOCUMENTADJUSTMENTCODEICMS_BR,RETAILATTRIBUTEMETADATA,BANKACCOUNTTABLE,ECORESTRACKINGDIMENSIONGROUPITEM,RETAILHARDWARECONFIGURATION,ECORESPRODUCTMASTERDIMVALUETRANSLATION,DIMENSIONFINANCIALTAG,TAXRUNTIMEMODELROWVERSION,FORMULADESIGNER_IN,RETAILPUBCATALOGPRODUCT,RETAILFISCALINTEGRATIONDOCUMENTPROVIDERTABLE,TAXPERIODHEADER,RETAILPOSITIONPOSPERMISSION,RETAILFORMLAYOUT,RETAILSTOREHOURSRANGE,SYSTASKRECORDERFRAMEWORKLEVEL,RETAILTENDERTYPECARDNUMBERS,TAXRUNTIMELOOKUPSTRUCTURE,TAXRUNTIMEDOCCOMPONENT,TAXSOLUTIONSCOPECHANGEHISTORY,MARKUPAUTOLINE,SYSTASKRECORDERFRAMEWORKLINE,TAXGROUPHEADING,BRAZILPARAMETERS,TAXFISCALCLASSIFICATION_BR,RETAILPUBRETAILCHANNELTABLE,LOGISTICSLOCATIONROLE,ECORESATTRIBUTEGROUPTRANSLATION,HCMPOSITION,TAXRTLOOKUPSTRUCTFIELDCONDCOLUMNLINK,RETAILBARCODEMASKTABLE,TAXMEASURETYPE,RETAILPOSSEEDDATA,RETAILIDENTITYPROVIDER,RETAILASSORTMENTPRODUCTLINE,RETAILMULTIBUYDISCOUNTLINE,RETAILENUMVALUETABLE,CUSTTABLE,FISCALCALENDARYEAR,RETAILOFFLINESCOPETABLES,RETAILPUBECORESCATEGORYTRANSLATION,RETAILLANGUAGETEXT,LANGUAGETXT,RETAILOPERATIONS,LOGISTICSELECTRONICADDRESS,TAXRUNTIMEDOCTAXTYPEVERSION,TAXTABLE,TAXRUNTIMEDOCCOMPONENTVERSION,ECORESATTRIBUTEGROUPATTRIBUTE,TAXRUNTIMELOOKUPCONDITION,HSNCODETABLE_IN,DIRPARTYTABLE,SALESPARAMETERS,LOGISTICSLOCATIONROLETRANSLATION,RETAILINTERNALORGANIZATION,ERTEXTFORMATTABLE,ECORESATTRIBUTE,TAXRUNTIMELOOKUPSTRUCTUREBINDING,RETAILBUTTONGRID,TAXDOCUMENTROWDETERMINEDCOMPONENT,RETAILSTORELOCATORGROUPOWNER,BUDGETSOURCE,TAXINFORMATIONCUSTTABLE_IN,RETAILFISCALPRINTERCONFIGTABLE,BUDGETCONTROLBUDGETCYCLE,TAXBENEFITCODESETUPHEADING_BR,TAXRUNTIMEMODELVERSION,BUDGETCYCLE,RETAILMEDIAPRODUCTRELATION,BUDGETPLANSCENARIO,TAXINFORMATION_IN,RETAILRECEIPTMASKS,RETAILPUBRETAILONLINECHANNELLANGUAGES,BUDGETSOURCETRACKING,RETAILTERMINALCOUNTER,RETAILBUTTONGRIDBUTTONS,HCMWORKER,INVENTSITELOGISTICSLOCATION,WMSLOCATION,RETAILEVENTNOTIFICATIONSETTING,TAXINFORMATIONLEGALENTITY_IN,ECORESCATEGORYHIERARCHY,BUDGETPLANLINE,RETAILTILLLAYOUT,RETAILCHANNELPRICEGROUP,DIMENSIONATTRVALUECOAOVERRIDE,ECORESPRODUCTDIMENSIONGROUPPRODUCT,RETAILINFOCODETABLESPECIFIC,WHSLICENSEPLATE,RETAILSTAFFEXTENDEDLOGON,RETAILMEDIAANDMASTERENTITYRELATION,RETAILSTAFFDEFAULTCOMMISSIONSALESGROUP,CUSTPACKINGSLIPTRANS,RETAILSTOREADDRESSBOOK,INVENTSERIAL,RETAILCHANNELTABLEEXT,INVENTITEMGROUPITEM,LOGISTICSADDRESSDISTRICT,RETAILREPORTLOCALIZEDSTRING,RETAILOFFLINEDATAEXPORTSCHEDULE,TAXRUNTIMEDOCCONTEXT,DIRPARTYLOCATION,TAXREGISTRATIONNUMBERS_IN,TAXMEASURETYPEDETAIL,TAXRUNTIMEPOSTINGTYPE,TAXRUNTIMELOOKUPSTRUCTUREBINDINGVERSION,RETAILKEYBOARDBUTTONCONTROL,RETAILLOYALTYSCHEMEEXCLUDEDAFFILIATION,RETAILFISCALINTEGRATIONFUNCTIONALITYPROFILE,RETAILTRANSACTIONSERVICEPROFILE,LOGISTICSLOCATIONEXT,CFOPGROUP_BR,RETAILATTRIBUTEFILTER,ECORESINSTANCEVALUE,RETAILLOYALTYSCHEMECHANNELEXPLODED,RETAILINFOCODEGROUP,EXCHANGERATETYPE,EXCEPTIONCODETABLE_BR,FISCALDOCUMENTSOURCETEXT_BR,RETAILCUSTAFFILIATION,RETAILASSORTMENTLOOKUP,RETAILTILLLAYOUTCONFIGURATION,RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION,BUDGETTRANSACTIONHEADER,RETAILIMAGES,PRICEDISCGROUP,ECORESTRACKINGDIMENSIONGROUPFLDSETUP,LEDGERENTRYJOURNAL,RETAILTERMINALCUSTOMFIELD,ECORESCATEGORYATTRIBUTELOOKUP,TAXRUNTIMEREFERENCEMODELATTR,RETAILTHEMEACCENT,INVENTTABLEMODULE,ERSOLUTIONTEXTFORMATVERSIONTABLE,RETAILPUBINVENTDIMCHANNELMETADATA,ECORESCONFIGURATION,GENERALJOURNALACCOUNTENTRY,RETAILCUSTTABLE,RETAILINFORMATIONSUBCODETRANSLATION,RETAILMEDIATEMPLATE,RETAILDISCOUNTPRICEGROUP,RETAILSTOREHARDWARESTATIONTABLE,TAXDOCUMENTROWTAXDETERMINEDINFO,WHSPARAMETERS,BUDGETCONTROLCONFIGURATION,RETAILAFFILIATIONTRANSLATION,LEDGERFISCALCALENDARPERIOD,SYSTASKRECORDERFRAMEWORK,ECORESCATEGORYHIERARCHYROLE,EFDOCAUTHORITY_BR,SHIPCARRIERTABLE,TAXRUNTIMEPOSTINGTYPEVERSION,INVENTLOCATION,INVENTLOCATIONDEFAULTLOCATION,RETAILSALESTAXOVERRIDEGROUP,TAXRUNTIMEDOCCONTEXTVERSION,TAXSOLUTIONINFO,SHIPCARRIERCOMPANYACCOUNTS,MARKUPTABLE,TAXRUNTIMEMEASURE,TAXRUNTIMELOOKUPSTRUCTUREFIELD,ERDATAMODELTABLE,BUDGETSOURCETRACKINGDETAIL,GENERALJOURNALENTRY_W,TAXONITEM,RETAILPRODUCTRATING,RETAILINVENTTABLE,RETAILPUBCATALOGINTERNALORG,RETAILFISCALINTEGRATIONFUNCTIONALITYPROFILEGROUP,RETAILSTORETABLE_IN,RETAILDLVMODECHANNELEXPLODED,RETAILCONFIGURATIONSTORETABLE_BR,TAXRUNTIMECOMPONENT,HCMPOSITIONWORKERASSIGNMENT,LEDGERJOURNALTABLE,OMHIERARCHYPURPOSE,RETAILFUNCTIONALITYPROFILE,CURRENCY,MAINACCOUNT,RETAILBARCODEMASKSEGMENT,RETAILOFFLINECUSTOMERADDRESSFILTER,RETAILSTANDARDATTRIBUTE,TIMEZONEINFO,BARCODESETUP,TAXGROUPDATA,RETAILSTAFFTABLE,RETAILJOBPOSPERMISSIONGROUP,EXCHANGERATE,CFOPMATRIX_BR,RETAILMEDIARESOURCE,TAXRUNTIMEREFERENCEMODELATTRVERSION,RETAILINFOCODEGROUPSPECIFIC,RETAILOFFLINEPROFILE,SYSTASKRECORDERFRAMEWORKINDUSTRYMAP,RETAILTHEMEACCENTCOLOR,RETAILHARDWARESTATION,UNITOFMEASURETRANSLATION,DIRPERSONNAME,TAXRUNTIMEDOCMODEL,ECORESTRACKINGDIMENSIONGROUPPRODUCT,OMHIERARCHYCHANGELOG,TAXREGISTRATION,TAXRUNTIMETAXTYPE,ECORESATTRIBUTETYPEUNITOFMEASURE,RETAILATTACHEDSERVICE,RETAILLOYALTYREWARDPOINTTRANSLATION,RETAILFISCALINTEGRATIONFUNCTIONALITYPROFILEGROUPLINE,INVENTSITE,RETAILOFFLINEPRODUCTSCATEGORY,ECORESATTRIBUTETRANSLATION,RETAILTENDERTYPECARDTABLE,EFDRETURNCODE_BR,ECORESCATEGORY,PRICEDISCTABLE,RETAILKIT,TAXRUNTIMELOOKUPSTRUCTUREFIELDBINDING,BUDGETPLANNINGSTAGE,RETAILSTAFFCREDENTIALTABLE,RETAILTILLLAYOUTSIZE,RETAILCONNPARAMETERS,TAXRUNTIMEMEASUREVERSION,CFOPTABLE_BR,FISCALESTABLISHMENTGROUP_BR,UNITOFMEASURE';

DECLARE @getTableName CURSOR
SET @getTableName = CURSOR FOR
SELECT Item
FROM dbo.SplitString(@ChangeTrackingTables, ',')
OPEN @getTableName
FETCH NEXT
FROM @getTableName INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
 SET @Sql  = ' IF (SELECT CASE (SELECT 1 WHERE '
 SET @Sql += QUOTENAME(@TableName,'''')
 SET @Sql += ' IN (SELECT OBJECT_NAME(object_id) [TABLE_NAME] FROM sys.change_tracking_tables)) WHEN 1 THEN 1 ELSE 0 END) = 0'
 SET @Sql += ' BEGIN '
 SET @Sql += ' ALTER TABLE '
 SET @Sql += @TableName
 SET @Sql += ' ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF); '
 SET @Sql += ' END '

 PRINT @Sql
EXEC (@Sql)
FETCH NEXT
FROM @getTableName INTO @TableName
END
CLOSE @getTableName
DEALLOCATE @getTableName


Full sync Database Dynamic 365
Scrip sql change Provide when clone database from cloud to on-premise Dynamic 365 Retail

Scrip sql change provide when clone database from cloud to on-premise Dynamic 365 Retail

Song Nghia - Technical Consultant

Update dbo.USERINFO set Enable = '1' 

Update dbo.RetailTransactionServiceProfile set AzureResource = 'https://usnconeboxax1aos.cloud.onebox.dynamics.com' 

Update dbo.RetailTransactionServiceProfile set ServiceHostUrl = 'https://usnconeboxax1aossoap.cloud.onebox.dynamics.com' 

Update dbo.RETAILCONNDATABASEPROFILE set ConnectionString = 'AQAAAHNm4l3JT6ikAPoAN//zuzANlILUc2biXclPqKQA+gA3//O7MA2UgtRPAwRDTnplG8+rzS9omxRxmMRG72nKnkzG8RyAzutFnbPmItYRZ3TJ+phMNjDIYIXzV/b/g0sZSExFdZgzDKWya6vZimKx8YCmMCdtl3b8h6VCVnFrRe1f62OKx6kf5DGG9g3JFWv/jfsJRldrgzZv0Wx/+a328WTxKHR/wgNtwTVyzWcc+krMwxLbAnSAtKBYQLD3ewn+MX76SONOmFjp/+sh9Ml5ZcLNHgOQen824hy261hutcBt5XwPYHoUVGw5dVMdurtX9Zp7mrKn0+Ep0W8UuDTbSkaNbm0UaNOVLLMVEIxgy8tIQinx0pz54n12zd0YPo/7NfQUY2Ud2OMNF7kpGZkDSVjUHEsYJRNkHn5g13VSdwxjJOfyy8Ad1y0Czxz4esCGLQWIgboPAXu5KNPYnfnILYVwmZZGLFy3o0TL75zvb6bAREpgSJi38Syjl1pspQm+8Vocs/vNnHpA8eM/f/o63Lx/KIzzwfFi40rVGEPyqgsnvCyMlqXxhnWoeuPEVVscuhEfcE7BCi/Sui2qaExzvNegUHb+G4kEbmBD8EjdHQl7w1a97tYiA+8ZEqsnaUIyrziSwWIUDQsUf7gAwT4bOdke7i8XrK38YRrVrq04U9JZYcvum4DOyEJ6sX7DzSzxUYYS5KBky61n064pO9HJu3idG1ym6Vgi1o/HepDb0TzIjTxJGYHclNVcZz5ttbQCeOOkTW+vnQr6maKzqK44cDdbUgs4Ik2vKagtDo7YToaWv/IcYVI/qSXpbCKLWjd5jsocMgP1+c/AJBouemSOyrvZfKvfoRWk56XAV1ELj0xBxedITv+5P/qWMh0iKeBDTJx1mtBYCaojQ+UPig9vFBUyQB3sE6e6pNGEeuIcv6avPCxnn2SK879vRCwsH6yRSnNpIqaxTQDe6JSKloAEgrZLgYlCOsINlHQi8wkf93BwxWLIXTWYqAmG0Mm1/y04Ydw+0sq+jeUQ' 

where Name = 'Default' 

Update dbo.RETAILCHANNELPROFILEPROPERTY set Value = 'https://usnconeboxax1ret.cloud.onebox.dynamics.com/Commerce' 

where ChannelProfile = '5637144576' and key_ = '1'  

Update dbo.RETAILCHANNELPROFILEPROPERTY set Value = 'https://usnconeboxax1pos.cloud.onebox.dynamics.com' 

where ChannelProfile = '5637144576' and key_ = '7' 

Update dbo.RETAILCHANNELPROFILEPROPERTY set Value = 'https://usnconeboxax1ret.cloud.onebox.dynamics.com/MediaServer/' 

where ChannelProfile = '5637144576' and key_ = '2' 

EXEC sp_addrolemember 'DataSyncUsersRole','axretaildatasyncuser'; 

EXEC sp_addrolemember 'db_owner','axretaildatasyncuser'; 

delete crt.DOWNLOADSESSIONDATAFILEHISTORY 

delete  ax.retailassortmentlookup 


Solution:  from my Technical Architect  in company.