Tuesday, February 28, 2023

Create main account lookup like general journal main account drop down through code X++, Dynamics 365 Finance and Operation

Create main account lookup like general journal main account drop down through code X++, Dynamics 365 Finance and Operation

 

Look up like below

Step : 01

·        Create a table with two below fields.

o    Account Type -> Base enum -> LedgerJournalACType

o   DefaultDimension -> EDT -> DimensionDynaminAccount

Step : 02

Add this table into your form datasource. DON’T update the property ‘Insert of empty = No’, left all properties as default. It will create a default line when datasource is initialized with value as ‘Ledger’ which will be parameterized for the DefaultDimension field.  You update Allow create/Delete/Check = No.

Step : 03

Create a datagroup control in the Form and drag two fields from the datasource table into the group.



Step : 04

Update the Default dimension properties with following values.



Step : 04

Attaching legal entity value, so that drop down will be populated with the selected LE’s data

  • ·        Add an unbound string control in the form and
  • ·        Override the modified method
  • ·        write the code as below.

[Control("String")]

    class LegalEntityContrl

    {

        public boolean modified()

        {

            boolean ret;

       

            DefaultDimension.setDataAreaId(LegalEntityContrl.text());

            AD_tmpMainAccountLedgerCategory.DefaultDimension = 0;

 

            ret = super();

       

            return ret;

        }

 

 

Step : 06

Build the project and validate

 

Note: This illustration will display all Main Accounts as drop down, if you want to display Customer/Vendor/Project and others then you need to create a record in the MainAccountLedgerCategory table with AccountType = ‘your required element’.


Multi-select record from a datasource under the clicked method in a form button code | X++ | D365 F&O | Dynamics 365 Finance and Operation

 Multi-select record from a datasource under the clicked method in a form button code x++


[FormControlEventHandler(formControlStr(EInvoiceCFDIJournal_PJ, AD_EInvoiceCFDIProjControllerOriginal_MX), FormControlEventType::Clicked)]

    public static void AD_EInvoiceCFDIProjControllerOriginal_MX_OnClicked(FormControl sender, FormControlEventArgs e)

    {

        Args args = new Args();

        ProjInvoiceJour         projInvoiceJour;

        FormDataSource projInvoiceJour_ds;

 

        projInvoiceJour_ds = sender.formRun().dataSource(formDataSourceStr(EInvoiceCFDIJournal_PJ, ProjInvoiceJour)) as FormDataSource;

        projInvoiceJour = projInvoiceJour_ds.getFirst(1);

        //     projInvoiceJour = projInvoiceJour_ds.cursor();

 

        while (projInvoiceJour.RecId != 0)

        {

        info(projInvoiceJour.ProjInvoiceId);

 

        projInvoiceJour = projInvoiceJour_ds.getNext();

        }

    }


Record from Data source from Form Event Handler X++ | | D365 F&0 | Dynamics 365 Finance

Record from Data source from Form Event Handler X++


[FormEventHandler(formStr(ProjInvoiceProposalDetail), FormEventType::Initialized)]

    public static void ProjInvoiceProposalDetail_OnInitialized(xFormRun sender, FormEventArgs e)

    {

 

        CustTable           custTable;

        ProjProposalJour    projProposalJour = sender.dataSource(formDataSourceStr(ProjInvoiceProposalDetail, ProjProposalJour)).cursor() as ProjProposalJour;

        FormCheckBoxControl isSpecialInvoiceFormat = sender.design().controlName(formControlStr(ProjInvoiceProposalDetail, ProjProposalJour_AD_IsSpecialInvoiceFormat)) as FormCheckBoxControl;       

        if(projProposalJour.OrderAccount)

            custTable = CustTable::find(projProposalJour.OrderAccount);

Monday, February 27, 2023

Get easy way to find element values of an base enum in D365 F&0 | Dynamics 365 Finance and Operation | X++

 Get element values of an base enum


SELECT * from ENUMVALUETABLE

join ENUMIDTABLE

on enumid = id

and ENUMIDTABLE.NAME = 'WorkflowTrackingType'

Get easy way table num | D365 F&0 | Dynamics 365 Finance and Operation | X++

Get table num from SQL Server AXDB DB 


select * from SysTableIdView where Name = 'TrvExpTable'

Open table in the browser | D365 F&0 | Dynamics 365 Finance and Operation

 Open table in the browser


Change table name and company from the bold area

https://environment.cloudax.dynamics.com/?mi=SysTableBrowser&tableName=Hcmworker&cmp=MHC

Get all disabled in from SQL Database

 Get all disabled in from SQL


select database and execute below command

select count(1) from sys.indexes where is_disabled = 1

Docentric report generation through code/batch from X++ | D365 F&0 | Dynamics 365 Finance and Operation

 Docentric report generation through code/batch


DocSrsReportGenerator docSrsReportGenerator = new DocSrsReportGenerator(controllerV2);
docSrsReportGenerator.setPrintDestinationSettings_DocentricReport(DocOutputFileFormat::PDF);

docSrsReportGenerator.generateDocentricReport();

Log file Shrink in SQL Database (AXDB_log) to 1 MB | D365 F&0 | Dynamics 365 Finance and Operation

Log file Shrink in SQL Database (AXDB_log) to 1 MB 


USE AxDB;

GO

-- Truncate the log by changing the database recovery model to SIMPLE.

ALTER DATABASE AxDB

SET RECOVERY SIMPLE;

GO

-- Shrink the truncated log file to 1 MB.

DBCC SHRINKFILE (AxDB_log, 1);

GO

-- Reset the database recovery model.

ALTER DATABASE AxDB

SET RECOVERY FULL;

GO

Number sequence generate from X++ | D365 F&0 | Dynamics 365 Finance and Operation | Code

 

public static AD_PaymentRemittanceId generateRemittanceId(NumberSequenceCode _numCode)

    {

        NumberSeq               num;

        string                  numSeqCode;

 

        if(!_numCode)

            throw error('Number sequence has not been configured');

 

        num             = numberSeq::newGetNumFromId(NumberSequenceTable::findByNaturalKey(_numCode).RecId);

        numSeqCode     = num.num();

        num.used();

 

        return numSeqCode;

    }