Wednesday 1 June 2022

Shrink db logs

 

  1. Right-click the AxDB database and select Properties -> Options.
  2. Set the recovery model to Simple and exit the menu.
  3. Right-click the database again and select Tasks -> Shrink -> Files.
  4. Change the type to Log .
  5. Under Shrink action, select Release unused space and click OK.
  6. Change recovery model to Full - Properties - Options.

Monday 21 February 2022

shrink db log

shrink db log 

ALTER DATABASE DYNAMICSXREFDB SET RECOVERY SIMPLE WITH NO_WAIT

DBCC SHRINKFILE(DYNAMICSXREFDB_log, 1000)

ALTER DATABASE DYNAMICSXREFDB SET RECOVERY FULL WITH NO_WAIT

Friday 11 February 2022

Create default dimensions in d365fo x++

 Create default dimensions in d365fo x++


public DimensionDefault createDefaultDimension(DimensionValue _CostC,                                                       

                                                    DimensionValue _department,

                                                    DimensionValue _branchCode )

    {

        DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();

        DimensionDefault                    ddim;

        int                                 i;

        DimensionAttribute                  dimensionAttribute;

        DimensionAttributeValue             dimensionAttributeValue;

        

        container               conAttr = ['CostCenter','Department','BranchCode'];

        container               conValue = [_CostC, _department, _branchCode];

        str                     dimValue;

    

        for (i = 1; i <= conLen(conAttr); i++)

        {

            dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

            if (dimensionAttribute.RecId == 0)

            {

                continue;

            }

            dimValue = conPeek(conValue,i);

            if (dimValue != '')

            {

                dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);

                valueSetStorage.addItem(dimensionAttributeValue);

            }

        }

    

        ddim = valueSetStorage.save();

        return ddim;

    }


Monday 31 January 2022

Get field Id d365fo x++ ax 2012

 Get field Id


DictTable dt; 

fieldId   fId; 

dt = new DictTable(tablenum(VendTable)); 

if (dt) 

    fId = dt.fieldName2Id("Name"); 

     print (strfmt("fId: %1", fId)); 

}

tax journal creation through code d365fo

 public void createTaxJournal(AirSalesTable _airSales, AirAmountTable _airAmount, LedgerJournalTable ljt,Amount  salesAmount,RefRecId leddim,

        Voucher _voucher,DebitCredit _debitCredit ,TaxEngineTaxJournalAccountType accountType ,SAC_IN _sacCode ,Amount _gstBaseAmount,NoYes   _gstApplicable,RefRecId _offsetLedgerDim )

    {

        TaxEngineTaxJournal             taxEngineTaxJournal;

        TaxEngineTaxJournalLine         taxEngineTaxJournalLine;

        TaxEngineTaxJournalLineTaxExtensionIN   taxEngineTaxJournalLineTaxExtensionIN;

        LedgerJournalName               ledgerJournalName;

        TradeGLSetupParameters      tradeGLParameters;

        TaxInformation_IN               taxInformation_IN;

        TaxRuntimeDocComponent          taxRuntimeDocComponent;

        TransTaxInformation             transTaxInformation;

        TaxComponentTable_IN            taxComponentTable_IN;

        TaxRuntimePostingType           taxRuntimePostingType;          

        TaxRuntimeDocTaxType            taxRuntimeDocTaxType;

        

        TaxEngineTaxJournalConstructor  taxEngineTaxJournalConstructor;


        select firstonly SalesTaxJournal,SAC from tradeGLParameters ;


        _sacCode = tradeGLParameters.SAC;


        select ledgerJournalName where ledgerJournalName.JournalName == tradeGLParameters.SalesTaxJournal

                && ledgerJournalName.DataAreaId == _airSales.CompanyCode;

        

        taxEngineTaxJournal.clear();

        taxEngineTaxJournalLine.clear();

        taxEngineTaxJournal.initValue();

        taxEngineTaxJournal.defaultRow();

        //taxEngineTaxJournal.JournalNum =  JournalTableData::newTable(taxEngineTaxJournal).nextJournalId();

        taxEngineTaxJournal.JournalNum              = TaxEngineTaxJournalUtil::getTaxJournalNum();

        taxEngineTaxJournal.insert();

            //NumberSeq::newGetNum(LedgerParameters::numRefJournalNum()).parmRefTableNum(; 

        taxEngineTaxJournalLine.TaxEngineTaxJournal = taxEngineTaxJournal.RecId;

        

        taxEngineTaxJournalLine.Purpose             =  TaxDocumentPurpose::Transaction;

        

                

        taxEngineTaxJournalLine.TransDate           = _airSales.ProcessedDate;

        taxEngineTaxJournalLine.Description         = _airSales.BookingNo;

        taxEngineTaxJournalLine.CurrencyCode        = _airSales.CurrencyCode;

        taxEngineTaxJournalLine.Triangulation       = Currency::triangulation(taxEngineTaxJournalLine.CurrencyCode);

        taxEngineTaxJournalLine.ExchRate            = ExchangeRateHelper::exchRate(taxEngineTaxJournalLine.CurrencyCode, taxEngineTaxJournalLine.TransDate, Currency::noYes2UnknownNoYes(taxEngineTaxJournalLine.Triangulation));


        taxEngineTaxJournalLine.AccountType         =  TaxEngineTaxJournalAccountType::Tax;

        

        taxEngineTaxJournalLine.LedgerDimension     =  leddim;

        


        if(_airAmount.TotalCgst != 0)

        {

            select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "CGST";

        }

        else if(_airAmount.Totaligst != 0)

        {

            select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "IGST" ;

        }

        if(_airAmount.TotalSgst != 0)

        {

            select RecId from taxRuntimeDocComponent where taxRuntimeDocComponent.Name == "SGST" ;

        }

        

        taxEngineTaxJournalLine.TaxComponent        = taxRuntimeDocComponent.RecId;

         


        select firstonly RecId from taxRuntimePostingType where taxRuntimePostingType.Name == "Tax Payable";

        

        taxEngineTaxJournalLine.TaxPostingType      = taxRuntimePostingType.RecId;

        taxEngineTaxJournalLine.OffsetAccountType   =  TaxEngineTaxJournalAccountType::Ledger;

        taxEngineTaxJournalLine.OffsetLedgerDimension = _offsetLedgerDim;

        //taxEngineTaxJournalLine.TaxMeasure = 

        //TaxEngineTaxJournalUtil::("GST", TaxEngineTaxJournalLine.OffsetTaxComponent);

        //taxEngineTaxJournalLine.    = _airSales.CompanyCode;

        //ledgerJournalTrans.ExchRate = exchRate;

        

         

        //taxEngineTaxJournalLine.LineNum++;

        //ledgerJournalTrans.Voucher = Numberseq::newGetVoucherFromCode(NumberSequenceTable::find(ledgerJournalTable.ledgerJournalName().NumberSequenceTable).NumberSequence).voucher();//bookingTable.MODocNum;

        

        //taxEngineTaxJournalLine.Voucher          = _voucher;

        

        //ledgerJournalTrans.DocumentDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

        if(_debitCredit == DebitCredit::Credit)

        {

            taxEngineTaxJournalLine.AmountCurCredit = salesAmount;

        }

        else

        {

            taxEngineTaxJournalLine.AmountCurDebit = salesAmount;

        }

        

        

        taxEngineTaxJournalLine.insert();

        


        taxEngineTaxJournalConstructor = TaxEngineTaxJournalConstructor::construct(taxEngineTaxJournalLine.TaxEngineTaxJournal().JournalType);

        //taxEngineTaxJournalConstructor.(taxEngineTaxJournalLine);

        taxEngineTaxJournalLine.update();


        //taxEngineTaxJournalLineTaxExtensionIN = taxEngineTaxJournalLine.TaxEngineTaxJournal();

                        

        

        taxEngineTaxJournalLineTaxExtensionIN.TaxEngineTaxJournalLine = taxEngineTaxJournalLine.RecId;

        

        

        taxEngineTaxJournalLineTaxExtensionIN.insert();


        transTaxInformation = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(taxEngineTaxJournalLine,true);

        transTaxInformation.ServiceAccountingCodeTable = ServiceAccountingCodeTable_IN::findByServiceAccountingCode(_sacCode);

        transTaxInformation.update();


        //TaxEngineTaxJournalUtil::postTaxJournal(taxEngineTaxJournal);


    }