Rabu, 14 April 2021

Mengaktifkan tombol di Docuview

https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/188370/how-to-enable-disable-delete-button-in-the-attachment-document-handling-based-on-enum-status/474532

Hi,

please have a look inside DocuView form, doReSearch method, around line number 160 and below. Hopefully you will see that there is already some code there that sets variable called 'allowEditBasedOnActualForm'.

In my installation there is even some code for Norway, which checks the calling table and sets the variable based on some fields - looks like exactly what you need ?

   if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoNO]) &&

      (testCursor.TableId == tablenum(CustInvoiceJour) || testCursor.TableId == tablenum(ProjInvoiceJour)))

   {

       switch (testCursor.TableId)

       {

           case tablenum(CustInvoiceJour):

               custTable = CustTable::find(CustInvoiceJour::findRecId(testCursor.RecId).InvoiceAccount, false);

               break;

           case tablenum(ProjInvoiceJour):

               custTable = CustTable::find(ProjInvoiceJour::findRecId(testCursor.RecId).InvoiceAccount, false);

               break;

       }

       if (custTable.EInvoice)

       {

           allowEditBasedOnActualForm = true;

       }

   }

Thanks,

Maciej

Senin, 12 April 2021

Mendefinisikan value dengan tipe data UTCDateTime

cara mendefinisikan value konstanta untuk tipe data UTCDateTime

tanggal 10 April 2021 jam 20:30:00

maka

UTCDateTime            jammakan;
;
jammakan = 2021-04-10T20:30:00

dan Bagaimana cara mendefinisikan UTCDateTime sama dengan Null ?

bisa dengan menggunakan method utcDateTimeNull();

contoh :

static void TestQueryBurndatetime(Args _args)
{
    RSPcmBlock              rspcmblok;
    RSPcmBlock              rspcmblokupdate;
    ;
    
    while select * from rspcmblok
        where rspcmblok.BurnedAreaDateTime >= 2019-04-07T00:00:00
        && rspcmblok.BurnedAreaDateTime <= 2019-04-07T11:59:00
    {
        info(strFmt("%1",rspcmblok.BlockId));
        select forUpdate rspcmblokupdate
        where rspcmblokupdate.BlockId == rspcmblok.BlockId;
        ttsBegin;
            rspcmblokupdate.BurnedAreaDateTime = utcDateTimeNull();
            rspcmblokupdate.update();
        ttsCommit;
    }
}

https://dynamicsaxposed.wordpress.com/tag/utcdatetime-blank-date/
https://stoneridgesoftware.com/dynamics-ax-all-about-dates-and-x/

Minggu, 11 April 2021

Export data to Excel via x++

https://visvashwalia.blogspot.com/2016/10/export-data-to-excel-from-microsoft.html?showComment=1618198356552#c3486349219749749881

Jadi kita sedang mencoba untuk code2 baru teruatam bagaimana export data to excel melalui x++.
dipostingan yang lama saya menggunakan ax2009.

sekarang kita akan menggunakan ax2012

static void ExportDatatoExcel(Args _args)
{
    SysExcelApplication            sysExcelApplication;
    SysExcelWorkbooks              excelWorkbookCollection;
    SysExcelWorkbook               excelWorkbook;
    SysExcelWorksheets             excelWorksheetCollection;
    SysExcelWorksheet              excelWorksheet;
    int                            i =1;
    str                            filename;
    vendTable                      vendTable;
    
    PSMRekapbayarsupplier          CustTableSelected; 
    ;


    // give the file name and save it to c drive
     filename = "C:\\A_Folder\\" + "ItemDetails5" +".xls";
    //"C:\\A_Folder\\" + "ItemDetails" + ".csv";

    // initlize the SysExcelApplication instance
    sysExcelApplication  = SysExcelApplication::construct();

    //create excel workbook and excel worksheet
    excelWorkbookCollection  = sysExcelApplication.workbooks();
    excelWorkbook    = excelWorkbookCollection.add();
    excelWorksheetCollection = excelWorkbook.worksheets();
    excelWorksheet = excelWorksheetCollection.itemFromNum(1);

    // excel column captions

    excelWorksheet.cells().item(i,1).value("Supplier");
    excelWorksheet.cells().item(i,2).value("Atas nama");
    excelWorksheet.cells().item(i,3).value("Bank");
    excelWorksheet.cells().item(i,4).value("No.Rek");
    excelWorksheet.cells().item(i,5).value("Total (Rp)");
    excelWorksheet.cells().item(i,6).value("Biaya transfer(Rp)");
    excelWorksheet.cells().item(i,7).value("Total (Rp)");
    
    i++;
    // fill the excel with vendtable Fields
    while select CustTableSelected
        where CustTableSelected.PSMJournalcashier == "GL21000556"
    {
        //if(i == 50)
         //break;

        excelWorksheet.cells().item(i,1).value(CustTableSelected.PSMName);
        excelWorksheet.cells().item(i,2).value(CustTableSelected.PSMName);
        excelWorksheet.cells().item(i,3).value(CustTableSelected.PSMToBankAccountname);
        excelWorksheet.cells().item(i,4).value(CustTableSelected.PSMToBankAccount);
        excelWorksheet.cells().item(i,5).value(num2str(CustTableSelected.PSMNominal,2,2,2,1));
        excelWorksheet.cells().item(i,6).value(CustTableSelected.PSMPaymFeeAmount);
        excelWorksheet.cells().item(i,7).value(CustTableSelected.PSMNominal+CustTableSelected.PSMPaymFeeAmount);
        
        i++;
    }

    //check the fileName is already exist
     if(WinAPI::fileExists(filename))
         WinAPI::deleteFile(filename);
     // save excel file
     excelWorkbook.saveAs(filename);

    // open excel file
    sysExcelApplication.visible(true);

    // close excel file
 // sysExcelApplication.quit();

}

coba lihat di bagian 

excelWorksheet.cells().item(i,5).value(num2str(CustTableSelected.PSMNominal,2,2,2,1));
excelWorksheet.cells().item(i,6).value(CustTableSelected.PSMPaymFeeAmount);

cell no 5 saya kenakan num2str
cell no 6 tidak.

hasil dari cell no 5 adalah nilai amount lengkap dengan separator decimalnya
sedangkan no 6 tidak ada separator dan decimal. sehingga seperti deret angka biasa.

Convert Amount to String

Hi Guys,

to do this dynamically, here is a solution:

System.Double netDouble;

anytype r1 = 1.125;

str s1;

netDouble = Global::real2double(r1);

s1 = netDouble.ToString();

info(strFmt("%1",s1));


https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/73896/convert-amount-money-to-string

Rabu, 07 April 2021

Menambah/menampilkan icon untuk mengetahui suatu line ada attachmentnnya

display smmDocIconNum showDocHandIcon()
{
    #macrolib.resource
    ;
    if ((select firstonly docuRef where docuRef.RefCompanyId  == this.DataAreaId && docuRef.RefTableId == this.TableId && docuRef.RefRecId == this.RecId).RecId)
    {
        return #RES_NODE_DOC;
    }

    return #RES_AM_NEW;
}

https://dynamicsuser.net/ax/f/users/70109/how-to-know-that-document-attached-or-not

Membuat string sql statement dan mengeksekusinya

Masih inget dengan programming diJava?... 
Bagaimana kita mengquery data dalam sebuah table?.
kita akan mendefinisikan Sql statmentnnya dalam sebuah string.

string        sqlstmt;
;
sqlstmt = "Select * from Mahasiswa";

atau

String     namatable;
String     sqlstmt;

;

namatable = "Mahasiswa";
sqlstmt = "Select * from "+namatable;

conn.execute(sqlstmt) //begitu kalo ga salah kalo diJava :D

Sekarang kita akan melakukannya di AX dengan bahasa x++
dengan menggunakan class
> Connection
> Statement

void Sample_1(void)

{
Connection Con = new Connection();
Statement Stmt = Con.createStatement();
ResultSet R =Stmt.executeQuery(‘SELECT VALUE FROM SQLSYSTEMVARIABLES’);

while ( R.next() )
{
print R.getString(1);
}
}


https://msdax.wordpress.com/2010/06/21/executing-sql-directly-from-x/

Erorr CS1963 - An expression tree may not contain a dynamic operation.

Kali ini saya mendapatkan erorr dengan code CS1963, padahal sebelumnya saya sudah mendefinisikan 'var item in Model' di @foreach(var...