Preserving the MorphX VCS when a Backup / Restore is needed.

Hello,
A very common situation is when developers need to update their database with fresh data from test or production environments, but the problem begins when you use the MorphX VCS and need to keep this data. Below I show the shortest and fastest way that I’ve found to do that:

First, we need to make a backup of the VCS data, for that, connect to the SQL Server using the Microsoft SQL Server Management Studio, choose the transactional database that you need to update with the fresh data and then run the commands:

1
2
3
4
5
6
7
--Creating a temp database to use on our process
CREATE DATABASE MyTempBackup
 
--Backuping the data
SELECT * INTO MyTempBackup.dbo.SysVersionControlMorphXItemTable FROM SysVersionControlMorphXItemTable
SELECT * INTO MyTempBackup.dbo.SysVersionControlMorphXLockTable FROM SysVersionControlMorphXLockTable
SELECT * INTO MyTempBackup.dbo.SysVersionControlMorphXRevisionTable FROM SysVersionControlMorphXRevisionTable

Now you can restore the fresh data on DEV’s environment and then we can restore our backed up data.

1
2
3
4
5
6
7
8
9
10
11
12
--Just to ensure that there is no trash on tables, you can skip this step
TRUNCATE TABLE SysVersionControlMorphXItemTable
TRUNCATE TABLE SysVersionControlMorphXLockTable
TRUNCATE TABLE SysVersionControlMorphXRevisionTable
 
--Restoring the data
INSERT INTO SysVersionControlMorphXItemTable SELECT * FROM MyTempBackup.dbo.SysVersionControlMorphXItemTable
INSERT INTO SysVersionControlMorphXLockTable SELECT * FROM MyTempBackup.dbo.SysVersionControlMorphXLockTable
INSERT INTO SysVersionControlMorphXRevisionTable SELECT * FROM MyTempBackup.dbo.SysVersionControlMorphXRevisionTable
 
--Removing the temp database
DROP DATABASE MyTempBackup

See ya,
Pichler





[AX2012] List all Financial Dimensions and his Values

Hello,
Very often I see developers doing a lot of code just to retrieve the keys and values of Financial Dimensions. To do that, you just need to list the values of DefaultDimensionView view, like you can see below.

1
2
3
4
5
6
7
8
9
10
11
12
static void showFinancialDimensions(Args _args)
{
    PurchTable              purchTable = PurchTable::find("INT-000060");
    DefaultDimensionView    defaultDimensionView;
    ;
 
    while select defaultDimensionView
      where defaultDimensionView.DefaultDimension == purchTable.DefaultDimension
    {
        info(strFmt("Dimension's name: %1 - Value: %2", defaultDimensionView.Name, defaultDimensionView.DisplayValue));
    }
}

Thank you Pedro!

[]s
Pichler





Atualizar a InventDim usando o FindOrCreate

Olá,
Abaixo um trecho de código onde atualizamos a inventdim, como vocês já devem saber, não deve-se atualizar a inventdim usando o método tradicional, isso porque cada ID é uma combinação de vários valores.

No exemplo abaixo, o usuário pediu para atualizar o número do lote de um relatório de conclusão utilizando alguns dados da própria OP.

public void modified()
{
    InventDim               myInventDim;
    ;
 
    super();
 
    myInventDim.data(InventDim); //InventDim é o meu DS do formulário, caso não tivesse um Buffer ativo eu usaria: myInventDim = InventDim::find(ProdParmReportFinished.InventDimId);
    myInventDim.inventBatchId = inventBatch.inventBatchId; //Aqui eu passo n novo lote
    myInventDim = InventDim::findOrCreate(myInventDim); //Aqui eu procuro por uma entrada igual a que eu preciso ou crio uma nova e atribuo o valor dela a myInventDim
 
    ProdParmReportFinished.selectForUpdate(true);
    ProdParmReportFinished.InventDimId = myInventDim.inventDimId;
    ProdParmReportFinished.update();
    ttsCommit;
}

[]s
Pichler





Olá Pessoal,
Tudo bem?

Pessoal essa semana passei por uma situação onde precisei adicionar uma referência fiscal no momento do faturamento de uma ordem de venda via código X++ no Microsoft Dynamics AX 2012 e gostaria de compartilhar com vocês caso passem pela mesma situação.

private void addFiscalReferenceAndPostSalesOrder(SalesId _salesId, EFDocAccessKey_BR _accessKey)
{
    SalesTable                      salesTable;
    SalesParmTable                  salesParmTable;
    FiscalReferenceController_BR    fiscalReferenceController;
    TmpFiscalReference_BR           tmpFiscalReference_BR;
    SalesFormLetter                 salesFormLetter;
 
    ttsBegin;
 
    //get SalesTable
    salesTable  =   salesTable::find(_salesId, false);
 
    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
 
    salesFormLetter.salesTable(salesTAble);
    salesFormLetter.transDate (systemDateGet());
    salesFormLetter.specQty (SalesUpdate::All);
 
    salesFormLetter.createParmUpdateFromParmUpdateRecord(salesFormLetter.salesParmUpdate());
 
    salesFormLetter.initParmSalesTable(salesTable);
 
    salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::After);
 
    salesFormLetter.initLinesQuery();
 
    //Get salesParmTable by ParmId
    select forUpdate firstOnly salesParmTable
        where salesParmTable.ParmId == salesFormLetter.parmId();
 
    //Add fiscal reference
    fiscalReferenceController = FiscalReferenceController_BR::construct(salesParmTable);
    tmpFiscalReference_BR.setTmpData(fiscalReferenceController.initTempTable());
 
    tmpFiscalReference_BR.initFromReferenceMap(FiscalDocument_BR::findByAccessKey(_accessKey));
    tmpFiscalReference_BR.LegalTextId = fiscalReferenceController.getDefaultLegalTextId();
    tmpFiscalReference_BR.insert();
 
    while select tmpFiscalReference_BR
    {
        fiscalReferenceController.writeTempTableRecord(tmpFiscalReference_BR);
    }
 
    //Post sales order
    salesFormLetter.run();
 
    ttsCommit;
}

Abraços,
Juliano Bachesque





Erro ao fazer check-in no MorphX X++ de registro já existe

Olá Pessoal,
Tudo bem?

Pessoal hoje encontramos um problema ao tentar fazer check-in no controle de versão MorphX VCS do Dynamics AX 2012 após restaurar uma base transacional de outro ambiente. Estou compartilhando com vocês caso se deparem com o mesmo problema

Ao realizar o procedimento de check-in ocorria o seguinte erro:

‘Não é possível criar um registro em SysVersionControlMorphXRevisionTable(SysVersionControlMorphXRevisionTable). O Registro já existe’.

Como solução indicada no link http://stackoverflow.com/questions/27488468/what-do-i-do-when-morphx-wont-let-me-check-in
executamos os seguintes passos:
1) Paramos a AOS
2) Executamos os comandos abaixo

UPDATE SYSSQMSETTINGS SET GLOBALGUID = '00000000-0000-0000-0000-000000000000'
DELETE FROM SYSCLIENTSESSIONS
DELETE FROM SYSSERVERSESSIONS

3) Reiniciamos a AOS e o processo de check-in ocorreu com sucesso.

Abraços,
Juliano





Tags / Categorias

RSS



Arquivo

Dynamics Community